+ 1
int main() { int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl; return 0; } i neeed a very simple discussion please about the loop i don't understand anything
3 Réponses
+ 4
This loop asks for the user to input an integer 5 times and adds that integer to the total 5 times.
I modified your code to display each step in the loop. See the link below, run the code, and enter 5 integers (each on a separate line) and then Submit to see it in action.
https://code.sololearn.com/c5OSQrdRqrXj/#cpp
0
MASSIVE thankkkss ❤❤
0
good and comprehensive explanation thanks