Coding:
#include<stdio.h>
#include <conio.h>
void main(){
int r,s,c=1,j,k;
clrscr();
printf("Enter an Odd Number: ");
scanf("%d",&r);
printf("\n");
s=r/2;
for(j=0;j<=r/2;j++)
{
for(k=s;k>=0;k--)
printf(" ");
s--;
for(k=c;k>0;k--)
printf("*");
c+=2;
printf("\n");
}
c=r-2;
s+=2;
for(j=r/2;j>=0;j--)
{
for(k=0;k<=s;k++)
printf(" ");
s++;
for(k=c;k>0;k--)
printf("*");
c-=2;
printf("\n");
}
getch();
}
Output:
No comments:
Post a Comment