mercredi 18 mars 2015

Can someone please help me with the "do" loop?



Write an application that keeps inputting an integer from the user until zero is entered.

The program will calculate and display the average of the numbers, and display the largest and smallest of the numbers.

Zero is not to be included in the average, largest or smallest printouts.



I tried it and got this far:



#include <iostream>
using namespace std;

int main () {
string str;
do {
cout << "Enter text: ";
getline (cin,str);
cout << "You entered: " << str;
cout <<str + str;
} while (str != "0");
}


but the problem is how do i get the average of the numbers with only one variable and how do i get the biggest and smallest number. I'm confused.




Aucun commentaire:

Enregistrer un commentaire