wap to print the following pattern.

                                     






















#include<stdio.h>
void main()
{
int i,j,n,a=1,k,m,b=1;
printf("enter the no. of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
 {
 for(j=1;j<=i-1;j++)
 printf("  ");
 for(k=b;k<=a;k++)
 printf("%d ",k);
 for(m=a-1;m>=b;m--)
 printf("%d ",m);
 }
 printf("\n");
 a=a+2;
 b=b+1;
 }
}



NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last

No comments:

Post a Comment

Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...