+ 2

I understand about prefix and postfix, but what is function num++ below this?

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

26th Nov 2019, 2:10 PM
Rrrrrr
Rrrrrr - avatar
1 Odpowiedź
+ 6
num is a variable you declared in the first line inside main(). Inside the while loop you are just incrementing that variable so it is updated every time before going for a condition check inside the while(). Sorry but it looks like you didn't understand prefix and postfix yet. Also num is not a function but a variable. Kindly consider revisiting the basics of the language.
26th Nov 2019, 2:15 PM
Avinesh
Avinesh - avatar