+ 1
What is the point of num++? Can someone please explain what will happen if i dont write num++?
please
2 ответов
+ 4
num++ is a simple way to write "num=num+1"
It's a common piece of code often use in loops and everywhere you need a step-by-step increment of a int variable.
If you miss to increment the check value in a loop you can have your program stuck in an infinite loop
Example:
int x = 0;
while (x < 5) {
cout << x << endl;
// This and the next line are not executed
// x++;
}
- 1
thanks a lot 😊😊