[Tutorial 7] 15.The figure gives a rough sketch of a running track. It includes a rectangular shape and two semi-circles. The length of the rectangular part is 67m and breadth is 21m.Calculate the distance of the running track.

 



#include <stdio.h>
#define PI 3.142
int main() 
{
float distance_rectangular, distance_semi_circles, total_distance;
float length_rectangular = 67.0; 
float breadth_rectangular = 21.0; 

distance_rectangular = 2 * length_rectangular ;
distance_semi_circles = 2 * PI * (breadth_rectangular/2);

total_distance = distance_rectangular +distance_semi_circles;

/* Display the total distance*/
printf("The distance of the running track is %.2f meters\n", total_distance);

return 0;
}


The provided code calculates the total distance of a running track composed of a rectangular part and two semicircular ends. It first initializes variables for the length and breadth of the rectangular part. Then, it computes the distances of the rectangular part and the semicircular ends separately. The distance of the rectangular part is calculated by doubling the length, representing the perimeter of the rectangle. The distance of the semicircular ends is calculated using the formula for the circumference of a circle, where the radius is half the breadth of the track. Finally, the total distance is obtained by summing the distances of the rectangular part and the semicircular ends. The result is printed out with two decimal places, indicating the total distance of the running track in meters.

Comments

Popular posts from this blog

Introduction To C

First C Program

Compilation process in c