0
What for num++ in this code?
#include <iostream> using namespace std int main() { int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl; return 0; }
2 Answers
0
num must be 6 in the end
0
Num++ adds the value of num by 1 in every loop until the loop is terminated (when num becomes 6). It basically means: num=num+1.