+ 4

what is the output? for (int a = 0; a < 10; a++) { cout << a << endl; }

c++ basic

22nd Jan 2018, 4:53 AM
Rachelle Cahayon
Rachelle Cahayon - avatar
9 Antworten
+ 8
The output will be like this :- 0 1 2 3 4 5 6 7 8 9 because it loops from 0 until the value is smaller than 10.But 10 is equal to ten. Therefore, It stops looping around.Endl makes a new line after every number.
22nd Jan 2018, 4:58 AM
Akash Pal
Akash Pal - avatar
+ 4
o to 9 loop
22nd Jan 2018, 4:55 AM
Akash Kumar Singh
Akash Kumar Singh - avatar
+ 4
@pelham it will not print from 0-10 it will print 0-9 because when it will be equal to 10 it will not satisfy the situation. from printing 0-10 you should add <= this sign in place of < . Got it.
11th Feb 2018, 11:37 AM
Akash Pal
Akash Pal - avatar
+ 1
same as akash
22nd Jan 2018, 3:26 PM
sagar hire
+ 1
same as akash
24th Jan 2018, 3:37 PM
abhijeet kulkarni
abhijeet kulkarni - avatar
0
О 9
22nd Jan 2018, 1:53 PM
iskand
0
I'm new to c++ but I do know Java and so it would print 0-9
24th Jan 2018, 1:11 AM
pelham Dathorne
pelham Dathorne - avatar
0
2
28th Jan 2018, 10:12 AM
Xyz
0
0-10
28th Jan 2018, 6:51 PM
pelham Dathorne
pelham Dathorne - avatar