write a c program to compute the perimeter and area of rectangle with a height of 7 inches and a width of 5 inches
Answers
#include <stdio.h>
int main() {
int radius;
float area, perimeter;
radius = 6;
perimeter = 2*3.14*radius;
printf("Perimeter of the Circle = %f inches\n", perimeter);
area = 3.14*radius*radius;
printf("Area of the Circle = %f square inches\n", area);
return(0);
}
Answer:
To calculate the perimeter and area of a rectangle 7 inches high and 5 inches wide, write a C program as follows:
main int() {
integer height=7, width=5;
int field = height * width;
int perimeter = 2 * (height + width);
printf("Area of rectangle = %d square inches\n", area);
printf("perimeter of rectangle = %d inches\n", perimeter);
returns 0;
}
In this program, we first declare two integer variables, height and width, and assign them the values 7 and 5, respectively. We then calculate the area of a rectangle by multiplying the height and width and assigning the result of the area to the integer variable . Also, we calculate the perimeter of the rectangle using the formula 2*(height + width) and assign the result to the integer variable perimeter.
Finally, we use the printf function to print out the calculated area and perimeter values with the appropriate units.
When we run the program, it shows the following information:
area of a rectangle = 35 square inches
perimeter of the rectangle = 24 inches
This shows that the area of the rectangle is 35 inches square and the perimeter is 24 inches.
View more C program questions :
https://brainly.in/question/55069241
#SPJ2