What function does 'num++' perform in WHILE LOOP ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What function does 'num++' perform in WHILE LOOP ?

#include <iostream> using namespace std; int main() { int num=1; int number; int total=0; while (num <= 6) { cin >> number; cout << total << endl; total += number; num++; } return 0; }

10th Dec 2020, 12:42 PM
MATTHEW CHRISTOPHER
MATTHEW CHRISTOPHER - avatar
2 Answers
0
MATTHEW CHRISTOPHER , incrementing variable num, if the variable is not incremented the loop never stops as the condition num <= 6, will be always true.
10th Dec 2020, 12:48 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
Thank you..
10th Dec 2020, 1:06 PM
MATTHEW CHRISTOPHER
MATTHEW CHRISTOPHER - avatar