Pyramid Programming

I'm trying to make a program that prints two pyramids next to each other. the program takes in an integer input from the user. for example. /

user enters 10
1
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10  10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9        9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8            8 7 6 5 4 3 2 1
1 2 3 4 5 6 7                7 6 5 4 3 2 1
1 2 3 4 5 6                    6 5 4 3 2 1
1 2 3 4 5                        5 4 3 2 1
1 2 3 4                            4 3 2 1
1 2 3                                3 2 1
1 2                                    2 1
1                                        1

for some reason my code is not formatting the numbers where i want them to be. here is my code. please help me find out what's wrong with my code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <conio.h>
main()
{
    int i, j, c;

    printf ("introduzca entero: ");
    scanf ("%d", &c);

    for (j = c; j >= 1; j = j - 1) // starts a loop that starts at c and ends at j is 1
    {
        printf ("\n");
        for (i = 1; i <= j; i++)
        {
            printf (" %d", i);
        }

         printf ("\t");
        for (i = j; i >= 1; i = i - 1)
        {
            
            printf ("%d ", i);
        }

 
   }
getch();

}  
Last edited on
conio is nonstandard and you are only using it to control your program's exiting; see the articles section or the Console Closing Down thread in this section for alternatives that are more reliable.
I couldn't hold back the style comment, but I use iostream not stdio so I'm not sure if I can help you with the printing. What does the current output look like? (using the above code)
Topic archived. No new replies allowed.