I didnt get this code | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

I didnt get this code

int num = 1; int number; while (num <= 5) { cin >> number; num++; } // here num is 1 & because of num++ we will get out put =1234 as condition is num<=5 m i right? but input we entered once only right???

28th May 2017, 11:05 AM
Vega
Vega - avatar
6 Respuestas
+ 4
int num = 1; int number; while (num <= 5) { cout << "enter a number: "; cin >> number; cout << num << " " << number << endl; num++; }
28th May 2017, 11:20 AM
Emore Anzolin
Emore Anzolin - avatar
+ 4
num=1<=5 print 1 num++ num=2<=5 print 2 num++ num=3<=5 print 3 num++ num=4<=5 print 4 num++ num=5<=5 print 5 now ur problem is solved?
5th Dec 2017, 9:32 AM
Shubham Nainwal
Shubham Nainwal - avatar
+ 3
num++ is post increment it means first use then change.
5th Dec 2017, 9:33 AM
Shubham Nainwal
Shubham Nainwal - avatar
+ 2
with this code you will have 5 input, over writing every time the previus what do you want to do?
28th May 2017, 11:11 AM
Emore Anzolin
Emore Anzolin - avatar
+ 1
you have take input in the variable number here you take input at each time loop runs mins you have take input from number 5 times here 5 times because condition is num<=5
28th May 2017, 11:11 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 1
i want output logic
28th May 2017, 11:14 AM
Vega
Vega - avatar