+ 3

Why is my output like this???

Please tell me what's wrong with this code. https://code.sololearn.com/cch6zhdd4Yth/?ref=app

22nd May 2018, 11:22 AM
Arjun Ajesh Pillai
Arjun Ajesh Pillai - avatar
10 Respuestas
+ 2
The for loop performs 10 iterations as x increments from 0 to 9. In each iteration, it prints the string "x" with no end of line characters, so the final output is xxxxxxxxxx If you want to print the integer x, remove the quotes. and you can add end of line with endl: cout<<x<<endl;;
22nd May 2018, 11:39 AM
ifl
ifl - avatar
+ 16
How u wanted the output to be...???
22nd May 2018, 11:35 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 15
//try this 👇 #include <iostream> using namespace std; int main() { for (int x=0;x<10;x++) { cout<<x<<"\n"; } return 0; }
22nd May 2018, 11:37 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 4
its:: cout<<x; not:: cout<<"x" youre outputting x as a string not as a variable
22nd May 2018, 11:34 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 3
type like this in cout <<x; it will print the for loop numbers if u want to write those numbers in separat lines then type like this in cout cout <<x<<endl; if u type cout with " this it will print the value inside the colons hop to help u
22nd May 2018, 12:41 PM
Jamaluddin Huseinkhail
Jamaluddin Huseinkhail - avatar
+ 2
cout<<x<<endl; or cout<<x<<"/n";
22nd May 2018, 1:58 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
+ 1
I wanted the output as this: 1 2 3 4 5 6 7 8 9
22nd May 2018, 11:36 AM
Arjun Ajesh Pillai
Arjun Ajesh Pillai - avatar
+ 1
Also 0
22nd May 2018, 11:37 AM
Arjun Ajesh Pillai
Arjun Ajesh Pillai - avatar
+ 1
Cлaвeн Ђервида That's "\n", with backslash as escape character. :-D
22nd May 2018, 7:03 PM
ifl
ifl - avatar
0
Thanks everyone.I got it!!!
22nd May 2018, 11:47 AM
Arjun Ajesh Pillai
Arjun Ajesh Pillai - avatar