67 178
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #10866 in C++ for Jo

Question #10866
Write a program (in C language not C++) which draws an “x” of user specified height. If the user typed 7,
the following series of ‘*’ characters would be drawn (without line
numbers):
1 2 3 4 5 6 7
1 * *
2 * *
3 * *
4 *
5 * *
6 * *
7 * *



Expert's answer
#include <stdlib.h>
#include <conio.h>
int main()
{
char
arrayofstar[100][100];
int height=0;
printf("Enter height:
");
scanf("%d",&height);
int k=height-1;
int count=0;
for(int
i=0;i<height;i++){

for(int
j=0;j<height;j++){
arrayofstar[i][j]='*';
if(i==j){
printf("%c",arrayofstar[i][j]);
}
if(i==count
&& j==k){
printf("%c",arrayofstar[i][j]);
}
else{
printf("
");
}
}
printf("\n");
count++;
k--;
}
getch();
return
0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions