quick question...in the loop below, what kind of code is neccessary to find the largest input entered by the user?
from my understanding, every iteration the variable changes and that is why I'm having a dilema?
Code tags added by Hammer.
//PURPOSE: This program reads an arbitrary number of real numbers.
//The input sequence is ended by a sentinel value.
//The program then reports the quantity, sum, and average
//of all numbers entered; how many of them are positive negative or
//zero;how many seven and elevens were entered, whether positive or
//negative; and the largest and smallest numbers entered.
#include<iostream.h> // for I/O tools
double num; //number the user will enter
//declaring counter variables to count number of times
//certain events occur.
//variables that will be assigned the total numbers
//varibles for largest and smallest number entered by user
float sum; //Computes the sum of user inputs
float average; //Computes the average of user inputs
//Setting these counts to zero because they all equal zero at
//this point in the program and so that the number of times the
//loop body is true corresponds to the number of the particular
//item the program keeps track of.
//So that my following sum assign.
//statements keep track of sum.
//Describing the program to user and also prompting the user.
//Also telling the user to input sentinel value when done.
cout<<"This program reports things about an arbitrary ";
cout<<"number of real numbers that\nyou will be asked " ;
cout<<"Enter any number or real numbers.";
cout<<" Following the last value you input,"<<endl;
cout<<"input 45.8931. Thank you!"<<endl<<endl;
//If statements within a loop. If the input doesn't equal
//the sentinel value,45.8931, the sum will be computed and
// count variable value will increment 1.
//Next, the If statements test to see if an event is true, and
//if so it increases the count of the variable name for that event
//Finally, we get the next user input just before the ned of the
average=sum/count; //computing the average
//Computing total sevens and elevens
//Formatting the output; reporting to the user the
// things about the number the user entered.
cout<<"The number of real numbers you entered is ";
cout<<"The sum of them is "<<sum<<"."<<endl;
cout<<"The average "<<average<<"."<<endl<<endl;
cout<<"You entered in "<<countpositives<<" positive ";
cout<<"numbers, "<<countnegatives<<" negative numbers, ";
cout<<"and "<<countzeros<<" zeros."<<endl<<endl;
cout<<"You entered in "<<countpositivesevens;
cout<<" positive sevens and "<<countnegativesevens;
cout<<" negative sevens, making a total of\n";;
cout<<totalsevens<<" sevens,whether positive or ";
cout<<" You entered in "<<countpositiveelevens;
cout<<" positive elevens and "<<countnegativeelevens;
cout<<" negative elevens, making a total of ";
cout<<totalelevens<<" elevens, whether positive ";