Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

oate a file called 1abs.G. In it. provid a C peogram that will do the Sollowing

ID: 3742702 • Letter: O

Question

oate a file called 1abs.G. In it. provid a C peogram that will do the Sollowing 2 Thes prempe te user se enter an inseper for the height eanisescelles triangle. This will be the same value for the hase A. Use loogs le draw an noceles trngle made of the character that the uner enficred. and using the beight entereldl by the er NOTE: Whea printing the charactr, prine i with a space immediately affer the character so the characters are evealy spaced hreeghout the triangle. For esample. with ne spaces afler the characleryeur shape will prist like his Whereas withs a spave afler ech charaer your shape will prit lkisch is hw i soeld be Print the value for the anc of the trangle with that hcig Sample outputs ane shown on est page. (hane would be the same as heigh SAMPLE OUTPUT Enter a character: Let'# draw an isoacelea triangle with your character A. Enter value 0r the height the triatgIQ1 Base will be the sane as height. The area of your triangle is 12.50 SAMPLE OLTPUT Entereharacters Let's deaw an isoaceles trlangle with your chareacter Ester value fot the height of the tELangle Base wi1 be the same as heighe

Explanation / Answer

#include <stdio.h>

int main()

{

char ch;

int h, b,i,j,k;

double area;

printf("Enter a Character: ");

scanf("%c", &ch);

printf("Let's draw an isosceles triangle with your character %c ",ch);

printf("Enter a value for the height of the triangle: ");

scanf("%d", &h);

b=h;

printf("(Base will be the same as height) ");

for (i = 1,k=1; i < h * 2; i += 2,k++) {

for (int j = 0; j < h * 2 - 1 - i / 2; j++) {

printf(" ");

}

for(j=1;j<=k;j++){

printf("%c ",ch);

}

printf(" ");

}

area = (h*b)/2.0;

printf("The area of your triangle is %.2f ",area);

return 0;

}

Output: