Advertisement
Sclafus

Dio cane

Nov 10th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int val, total = 0, counter = 0;
  5. cout << "Val (0 to finish)? " << endl;
  6. cin >> val;
  7. while (val != 0) {
  8.     total += val;
  9.     counter++;
  10.     cout << "Val (0 to finish)? " << endl;
  11.     cin >> val;
  12. }
  13. if (counter > 0) {
  14.     cout << "Avg: " << total / float(counter) << endl;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement