C Program to print numeric pyramid

CWC
1 Min Read

C Program to print numeric pyramid

C Program to print numeric pyramid – Program – 1

# include <stdio.h>
# include <conio.h>
main()
{
int i,j;
clrscr( );
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
printf(“%d”,j);
printf(“\n”);
}
getch();
}

C Program to print numeric pyramid – Program – 2

# include <stdio.h>
# include <conio.h>
main( )
{
int i,j ,l,k=40;
clrscr( );
for(i=1;i<=9;i+=2)
{
for(l=1;l<=k;l++)
printf(“ “ );
for(j=1;j<=i;j++);
printf(“%d”,j);
printf(“\n”);
k=k-2;
}
getch( );
}

C Program to print numeric pyramid – Program – 3

# include <stdio.h>
# include <conio.h>
main( )
{
int i,j,l,n,s,k=40;
clrscr( );
for(i=1;i<=9;i+=2)
{
for(l=1;l<=k;l++)
printf(“ “);
for(j=1;j<=i;j++)
printf(“\n”);
k=k-2;
}
k=k+4;
for(n=7;n>=1;n-=2)
{
for(i=1;i<=k;i++)
printf(“ “);
for(s=1;s<n;s++)
printf(“%d”,s);
printf(“\n”);
k=k+2;
}
getch( );
}

 

Save

Save

Save

Save

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version