1 2 3 4
2 3 4
3 4
4
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int r, p, k,g=0,h=1;
clrscr();
printf("\n enter the no of row");
scanf("%d", &r);
for ( k = r ; k >= 1 ; k-- )
{
for ( p = 1 ; p <= g; p++ )
printf(" ");
g++;
for ( p = h;p <=r ; p++)
printf("%d", p);
h++;
printf("\n");
}
getch();
}
Output:
2 3 4
3 4
4
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int r, p, k,g=0,h=1;
clrscr();
printf("\n enter the no of row");
scanf("%d", &r);
for ( k = r ; k >= 1 ; k-- )
{
for ( p = 1 ; p <= g; p++ )
printf(" ");
g++;
for ( p = h;p <=r ; p++)
printf("%d", p);
h++;
printf("\n");
}
getch();
}
Output: