Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int val, total = 0, counter = 0;
- cout << "Val (0 to finish)? " << endl;
- cin >> val;
- while (val != 0) {
- total += val;
- counter++;
- cout << "Val (0 to finish)? " << endl;
- cin >> val;
- }
- if (counter > 0) {
- cout << "Avg: " << total / float(counter) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement