Error(s) found: '1'

  • Unable to perform the query 'UPDATE cpp_code SET clickthru=clickthru+1 WHERE fid=15'. Table 'cpp_code' is read only.

  • C++ MADE EASY
    Code About Us Tutorial




       
     

    Home > myCode > Average, Max. and Min. of Numbers

    November 28, 2009 8:29 pm

       

    Average, Max. and Min. of Numbers


    Posted on: 2001-10-22 08:58:28
    Number of times viewed: 484

     
     
    /* Given that only positive numbers are entered, this program computes and
    outputs the average, maximum, and minimum. -1 signifies the end of the input.*/
    #include <iostream.h>
    #include <conio.h>
    
    main()
    {
       int input = 0;
       int divide = 0;
       int number;
       int max = 0;
       int min = 1000;
       float average, total;
    
       cout <<"Enter numbers you wish to average \nWhen you are done type -1.";
    
       while (input != -1)
       {
          total += input;
          divide++;
          cout <<endl <<"Enter a number:  ";
          cin >> input;
    
          if(input >= max)
             max = input;
             if(input <= min)
             {
             if(input != -1)
               min = input;
             }
             else
               min = min;
       }
    
       --divide;
       average = total / divide;
    
       cout <<endl <<"The average is " <<average;
       cout <<endl <<"The max. number entered was: " <<max;
       cout <<endl <<"The min. number entered was: " <<min;
       getch();
    }

    Please Rate this Code:



     «12039» THINKQUEST TEAM C0111571 © 2001. All Rights Reserved.