Commit 63a1f2fd authored by Karine's avatar Karine

Exercise_05_06, Version2

parent 04ac6a5d
......@@ -6,21 +6,18 @@ main()
int sum = 0;
int count = 0;
std::cout << "Enter the numbers (9999 is the last number): ";
std::cout << "Enter the numbers (9999 to exit): ";
for (int i = 1; i > 0; ++i) {
while (true) {
int number;
std::cin >> number;
if (number == 9999) {
sum += number;
count++;
if (9999 == number) {
break;
}
sum += number;
count++;
++count;
}
double average = sum / count;
......
Enter the numbers (9999 is the last number): Average is 1286
Enter the numbers (9999 to exit): Average is 42
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment