1. ## c programming exercise

i need to write the code for this problem:
Q:write a c program to print a pyramid of digits as shown below for n number of lines.
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
-- -- -- -- -- -- -- --
Actually i have the code as well.But something is wrong. heres the code:
Code:
```/*program to print digits in pyramidal form*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l,m,n;
clrscr();
printf("\n how many lines?");
scanf("%d",&n);
/*loop 1 to print n lines*/
for(l=1;l<=n;l++)
{
/*loop 2 to print spaces*/
for(i=1;i<=n-l;i++)
printf("       ");
/*loop to print digits in the left side of axis*/
m=l;
for(j=1;j<=l;j++)
{
printf("%6d",m);
m++;
}
/*loop to print digits rightside of axis*/
m=m-2;
for(k=1;k<l;k++)
{
printf("%6d",m);
m--;
}
printf('\n");
}
getch();
}```
i ran the code on borlands turbo c++ 3.0 and in the output only the right
side of the axis came. i am unable to figure out the mistake in the code.

2. the pyramid should have been like this:
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4

3. Code:
```#include <stdio.h>

int main(void){
int i, j, space, repeats;
repeats = 5;
for(i = 1; i <= repeats; i++){
space = repeats-i;
while(space-- > 0) printf(" ");
for(j = i; j < 2*i-1; j++)
printf("%d", j);
for(j = 2*i-1; j > i-1; j--)
printf("%d", j);
putchar('\n');
}
}```
edit:
if you want spaces between the numbers you can change :

space = repeats-i to space = 2*(repeats-i)

and the printf statements to

printf("%d ", j);

also only works at a max of 5 lines.

4. i ran the code on borlands turbo c++ 3.0 and in the output only the right
side of the axis came. i am unable to figure out the mistake in the code.
`printf('\n");`
`printf("\n");`