1 121 123211234321 /*program to print in a given format*/
#include<stdio.h>
#include<conio.h>
int main(){
int i,j,k,n,k,l;
clrscr();
printf(“enter the value of n”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-1;j++)
{
printf(“ ”);
}
for(k=1;k<=i;k++)
{
printf”(%d”,k);
}
for(l=i-1;l>=I;l--)
{
printf(“%d”,l);
}
printf(“\n”);
}
getch();
return 0;
}
output
enter the value of n 41
121
12321
1234321
Comments
Post a Comment