Write a “C” program to calculate the area of the following geometric shape. It\'
ID: 3597652 • Letter: W
Question
Write a “C” program to calculate the area of the following geometric shape. It's a pentagon with a square on the bottom and a triangle on the top. All the sides (both triangle and square) are length of D. I know how to calculate area of a triangle and the square. My question I have is how to add the two functions together, how to introduce a variable as the base and height value. When i keep trying to input D it gives me that the answer is 0. Furthermore, is calculating the area of a square plus a triangle the same as calculating the area as a pentagon if you were to add it together.
Explanation / Answer
#include <stdio.h>
#include <conio.h>
int main(){
float length, width, area;
printf("Enter length of Rectangle ");
scanf("%f", &length);
printf("Enter width of Rectangle ");
scanf("%f", &width);
/* Area of Rectangle = Length X Width */
area = length * width;
printf("Area of Rectangle : %0.4f ", area);
getch();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.