+ 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???
6 ответов
+ 4
int num = 1;
int number;
while (num <= 5) {
cout << "enter a number: ";
cin >> number;
cout << num << " " << number << endl;
num++;
}
+ 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?
+ 3
num++ is post increment it means first use then change.
+ 2
with this code you will have 5 input, over writing every time the previus
what do you want to do?
+ 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
+ 1
i want output logic