for n=5
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
code is below:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
int main()
{
int num;
printf("Enter the number\n");
scanf("%d", &num);
for (int i = 1; i <= num; i++)
{
for (int j = 1; j <= (num * 2); j++)
{
if (j >= i && j <= ((num * 2) + 1) - i)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Comments
Post a Comment