Write a C program to compute the perimeter and area of a rectangle with a height of 5 inches. and width of 3 inches

Write a C program to compute the perimeter and area of a rectangle with a height of 5 inches. and width of 3 inches

Expected Output:
Perimeter of the rectangle = 16 inches
Area of the rectangle = 15 square inches

#include <stdio.h> 
/* height and width of a rectangle in inches */
int width;          
int height;         

int area;           
int perimeter;      

int main() {
    height = 5;
    width = 3;

    perimeter = 2*(height + width);
    printf("Perimeter of the rectangle = %d inches\n", perimeter);
    
    area = height * width;
    printf("Area of the rectangle = %d square inches\n", area);

return(0);
}

Result

Write a C program to compute the perimeter and area of a rectangle with a height of 5 inches. and width of 3 inches
Write a C program to compute the perimeter and area of a rectangle with a height of 5 inches. and width of 3 inches

 

 

Leave a Comment