Sunday, 21 January 2018

Program for Diamond


Program for Diamond
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j,k,nol;
clrscr();
printf("Enter the value:");
scanf("%d",&nol);
for(n=1;n<=nol;n++)
{
for(i=1;i<=40-n;i++)
printf("   ");
for(j=1;j<=n;j++)
printf("%3d",j);
for(k=n-1;k>0;k--)
printf("%3d",k);
printf("\n");
}
for(n=nol;n>=1;n--)
{
for(i=1;i<=40-n;i++)
printf("   ");
for(j=1;j<=n;j++)
printf("%3d",j);
for(k=n-1;k>0;k--)
printf("%3d",k);
printf("\n");
}
getch();
}�

0 comments:

Post a Comment