Filled Under:

C program to print the pattern.

C program to print the pattern

C program to print the pattern.

 In this program, I have discussed about the C program to print the pattern shown above.


#include<stdio.h>
int main()
{ int i,j,k,p=1,l,q=2,r=1,c=0,m=1,z=1,y=1;
for(i=1;i<=5;i++)
{
for(j=5;j>i;j--)
{ printf("  ");
}
k=z;
while(k<=y)
{printf("%d ",k);
k++;
}
y+=2,z++;
if(c!=0)
{
l=q,p=r;
while(l>p)
{printf("%d ",l);
l--;}
q+=2,r++;
}
c++;
printf("\n");
}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.



0 comments:

Post a Comment

 

Copyright 2020 Programming in C All Right Reserved