Posted by : Unknown
Wednesday, February 3, 2016
******
* *
**
**
* *
******
Ans:
#include<stdio.h>
int main(int argc, char *argv[])
{
int height = 1;
int i, j;
while((height % 2 != 0) && height > 0){
printf("Enter Height: ");
scanf("%d",&height);
}
/*first half*/
for(i = 0; i < height; i++) putchar('*');printf("\n");
for(i = 1; i < height/2; i++){
for(j = 0; j < height; j++) {
if(j == i || j == (height-i-1))putchar('*'); else putchar(' ');
} printf("\n");
}
/*second half*/
for(i = height/2 -1; i > 0; i--){
for(j = 0; j < height; j++){
if(j == i || j == (height - i - 1))putchar('*'); else putchar(' ');
} printf("\n");
}
for(i = 0; i < height; i++) putchar('*');
return 0;
}
**********OUTPUT**********
Enter Height: 6
******
* *
**
**
* *
******
*************************
Related Posts :
- Back to Home »
- Star Patterns »
- 27.Hollow X shape as using *'s as shown below.