Can I get a space!

My program works fine but I cant seem to remove the extra space between lines.

It should look like this;
5| *
4| *
3| *
2| *
1| *
0|*
-1| *
-2| *
-3| *
-4| *
-5| *

but instead it looks like this;
5| *

4| *

3| *

2| *

1| *

0|*

-1| *

-2| *

-3| *

-4| *

-5| *

Any suggestions to point me in the right direction?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using namespace std;
int main()
{
    int x,y;  
    for(y=5; y>-6; y--)
          {
                   x=pow(y,2);
                   x++;
                   cout << setw(2) << y << "|" << setw (x);
                   cout << "*" << endl;
          {         
                   cout << endl;
          }

                        
}              
system("PAUSE"); 
return 0;

  
}        

The braces at lines 11 and 13 serve no purpose, remove them.
The endl at lines 10 and 12 output the newline character. You should get rid of one or the other.

By the way, you could use the [output][/output] tags to format the program output properly, like this:
 5|                        *
 4|               *
 3|        *
 2|    *
 1| *
 0|*
-1| *
-2|    *
-3|        *
-4|               *
-5|                        *
Last edited on
Topic archived. No new replies allowed.