C program to calculate room to paint and the room to be whitewashed - IProgramX

Q. C Program - Consider a room having one door and two windows both of the same size. accept dimensions of the room, door and window. print the area to be painted (interior walls) and area to be whitewashed (roof)


Program

#include <stdio.h>
int main()
{
float room_width, room_length, room_height, door_length, door_height, window_length, window_height, paint_area, whitewash_area;
printf("Enter dimensions of room (Length, Width, Height) in order:\n");
scanf("%f%f%f", &room_length, &room_width, &room_height);
printf("Enter dimensions of door (Length, Height) in order:\n");
scanf("%f%f", &door_length, &door_height);
printf("Enter dimensions of window (Length, Height) in order:\n");
scanf("%f%f", &window_length, &window_height);
paint_area = 4*room_length*room_height - door_length *door_height - 2*window_length*window_height;
whitewash_area = room_length*room_width;
printf("Area to be painted:\t%f\n", paint_area);
printf("Area to be whitewashed:\t%f\n", whitewash_area);
}

Output:

Enter dimensions of room (Length, Width, Height) in order:
10 12 10
Enter dimensions of door (Length, Height) in order:
4 7
Enter dimensions of window (Length, Height) in order:
4 4
Area to be painted         : 340.000000
Area to be whitewashed: 120.000000

Post a Comment

1 Comments