+ 3
Why is my output like this???
Please tell me what's wrong with this code. https://code.sololearn.com/cch6zhdd4Yth/?ref=app
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;;
+ 16
How u wanted the output to be...???
+ 15
//try this 👇
#include <iostream>
using namespace std;
int main() {
for (int x=0;x<10;x++)
{
cout<<x<<"\n";
}
return 0;
}
+ 4
its::
cout<<x;
not::
cout<<"x"
youre outputting x as a string not as a variable
+ 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
+ 2
cout<<x<<endl; or cout<<x<<"/n";
+ 1
I wanted the output as this:
1
2
3
4
5
6
7
8
9
+ 1
Also 0
+ 1
Cлaвeн Ђервида That's "\n", with backslash as escape character.
:-D
0
Thanks everyone.I got it!!!