0
while loop
int num = 1; while (num < 6) { cout << "Number: " << num << endl; num = num +1; } in this case o/p is:Number: 1 Number: 2 Number: 3 Number: 4 Number: 5 Number: 6 but instead of num=num+1 if i write num=num++ it is giving o/p as number:1 number:1 . . . infinite times why?
3 odpowiedzi
0
you should user num++
num = num + 1
or
++num
or
num++
0
That u have written is
num = num = num + 1
0
It will give you syntax error