Horizontal something like this.
For n = 11
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
#include<stdio.h>
#include<conio.h>
int main()
{
int c,i,n,space;
printf("Enter the number of rows you want on the Pyramid\n");
scanf("%d",&n);
clrscr();
space=n;
for(i=1;i<=n;i++)
{
for(c=1;c<=space;c++)
{
printf(""); // only the space has been changed - printf("") instead of printf(" "); and printf("* ");
}
space--;
for(c=1;c<=i-1;c++)
{
printf("* ");
}
printf("\n");
}
space=2;
for(i=1;i<=n;i++)
{
for(c=1;c<=space;c++)
{
printf(""); // only the space has been changed - printf("") instead of printf(" "); and printf("* ");
}
space++;
for(c=1;c<=n-i-1;c++)
{
printf("* ");
}
printf("\n");
}
getch();
return 0;
}
No comments:
Post a Comment