adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

print following patterns

print following patterns

1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
 #include<stdio.h>  
 #include<conio.h>  
   void main()  
    {  
     int i,j;           
     clrscr();  
     for(i=0;i<=5;i++)  
        {  
       for(j=1;j<=5-i;j++)  
         printf(" ");  
        for(j=1;j<=i;j++)  
         printf("%2d",j);  
        for(j=i-1;j>=1;j--)  
         printf("%2d",j);  
        printf("\n");  
        }  
       getch();  
      }  
Output:-


Post a Comment

0 Comments