C : Program for printing asterisk in diamond shape
Oct 19, 2023
Program :
//c program for printing asterisk in diamond shape
#include<stdio.h>
int main()
{
int rows;
printf("Enter number of rows : ");
scanf("%d", &rows);
for(int i=1; i<=rows; i++)
{
for(int j=1; j<=rows-i; j++)
{
printf(" ");
}
for(int j=1; j<=2*i-1; j++)
{
printf("*");
}
printf("\n");
}
for(int i=rows-1; i>=1; i--)
{
for(int j=1; j<=rows-i; j++)
{
printf(" ");
}
for(int j=1; j<=2*i-1; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Output:
