New course! Every coder should learn Generative AI!
Try a free lesson- 2
I'm not understanding this. How's num used here??
6 Answers
+ 5
Please make your questions clear with using relevant tags. As this is unclear questions
https://www.sololearn.com/discuss/1316935/?ref=app
+ 3
num is a variable here used to control the loop. In other words the value of 'num' variable will decide whether the code inside loop will execute or not as after each execution the value of num is increasing by 1 so the loop will not continue to run after a specific number of executions.
Thank you
+ 2
Where? Please upload your question properly so that community can help you.
+ 1
int num = 1;
int number;
int total = 0;
while (num <= 5) {
cin >> number;
total += number;
num++;
}
cout << total << endl;
return 0;
}
0
What is num doing here
I mean how is it interacting with number
0
Ok