0

can anyone discuss it to me in a simple way

27th Sep 2016, 4:33 PM
Retag Tarek
Retag Tarek - avatar
3 Réponses
+ 1
can you show me the programme?
27th Sep 2016, 4:35 PM
daniele
daniele - avatar
+ 1
First num is assigned the value 1. The while loop checks to see if num is less than 6. If the condition is met, it runs. If not, it skips past the while loop. The first time, num = 1 so the loop executes. In the loop, cout is a command to print output to the screen. "number" is a string it prints, then the variable num, then endl which is a return AKA line break. Finally, the value of num is increased by 3. So num now equals 4. Then the while loops checks to see if it should run again. Since 4 < 6, it will execute again the same way, but this time at the end num will be increased to 7. So when the loop checks num < 6 again, it will be checking 7 < 6. Since this is not true, the while loop does not execute and the program is complete. The output will look something like: number = 1 number = 4
28th Sep 2016, 12:13 AM
Ryne
Ryne - avatar
0
int num=1 while (num<6) { cout << "number" << num <<endl; num=num+3 ; } it maybe seems easy but i am just a beginner 😃
27th Sep 2016, 4:40 PM
Retag Tarek
Retag Tarek - avatar