C Program Code for Printing Diamond Shape

Program Code:


#include<stdio.h>
int main()
{
int a=10 ,b =9 ;
int i,j,k,x,y,z;
for(i =1;i<=10;i++)
{
for(j =1;j<=a;j++)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("*");
printf(" ");
}
a--;
printf("\n");
}
for(x =1;x<=9;x++)
{
for(z = 1;z<=x;z++)
{
printf(" ");
}
for(y=1;y<=b;y++)
{
printf(" ");
printf("*");
}
printf("\n");
b--;
}
return 0;
}

Output:

.exe file

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.