How it stores the last value of the num? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

How it stores the last value of the num?

When the while is checking that 2 is less than 8 and prints the num that is 2. So how does it creates the nums " 4 5 6 7", as i havnt mentioned them or declared anywhere.

28th Dec 2018, 11:08 AM
Nomi Rajput
Nomi Rajput - avatar
4 ответов
+ 5
Nomi Rajput Post your code to solve the error
28th Dec 2018, 11:15 AM
deeyae
deeyae - avatar
+ 5
First iteration : num=2 < 8 prints Number: 2 num=3 Second iteration : num=3 < 8 prints Number: 3 num=4 Third iteration : num=4 < 8 prints Number: 4 num=5 Fourth iteration : num=5 < 8 prints Number: 5 num=6 Fifth iteration : num=6 < 8 prints Number: 6 num=7 Sixth iteration : num=7 < 8 prints Number: 7 num=8 And after the loop becomes false and the loop terminates And the output will be 2 3 4 5 6 7 You haven't mentioned them but it is the while loop's duty to print that numbers
29th Dec 2018, 2:15 AM
deeyae
deeyae - avatar
0
you need post a code so we understand what you are talking about and specify what language you're using in the tags
28th Dec 2018, 11:27 AM
Asirap
0
int num = 2; while (num < 8) { cout << "Number: " << num << endl; num = num + 1; }
28th Dec 2018, 11:30 AM
Nomi Rajput
Nomi Rajput - avatar