Think about this logically. You want to output a and then output b and then AFTER THAT have a newline. Try your putting your newline in a place that achieves this.
//output a
//output b
//newline
//output b
//newline
//etc
oh yes finally i have found out that.
it's something like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main()
{
for (int a=0 ; a<=3 ; a++)
{
cout<<a;
for (int b=0; b<=5 ; b++)
{
cout<<"\t"<<b<<endl;
}
cout<<endl;
}
return 0;
}
But one thing that i still can't understand is with "\t". This \t means some amount of spaces(tab) 4 or 5 i don't remember. But when I replace this with manual " "(spaces in between), it gives me slightly misplaced output.
Yes.
line 9 in your last code cout << a occupies a space and when "appears" b from line 12 will be shifted. Then loop with b goes on without that "a" till the end of the loop b and so on.
EDIT: If all OK please mark this thread as Solved.