30. A building has 10 floors with a floor height of 3 meters each. A ball is dropped from the top of the building. Find the time taken by the ball to reach each floor. (Use the formula s = ut+(1/2)at^2 where u and a are the initial velocity in m/sec (= 0) and acceleration in m/sec^2 (a= 9.8 m/s^2)).


 

Program for a building has 10 floors with a floor height of 3 meters each. A ball is dropped from the top of the building. Find the time taken by the ball to reach each floor. (Use the formula s = ut+(1/2)at^2 where u and a are the initial velocity in m/sec (= 0) and acceleration in m/sec^2 (a= 9.8 m/s^2)).

Source Code:

#include <stdio.h>

#include<math.h>

void main()

{

int s=3,i=10;

float a=9.8,u=0,t;

while(s<=30)

{

t=sqrt(2*s/a);

printf("The time taken to reach %d  floor is %f sec\n",i-1, t);

i--;

s=s+3;

}

}

Output:


The time taken to reach 9  floor is 0.782461 sec

The time taken to reach 8  floor is 1.106567 sec

The time taken to reach 7  floor is 1.355262 sec

The time taken to reach 6  floor is 1.564922 sec

The time taken to reach 5  floor is 1.749636 sec

The time taken to reach 4  floor is 1.916630 sec

The time taken to reach 3  floor is 2.070197 sec

The time taken to reach 2  floor is 2.213133 sec

The time taken to reach 1  floor is 2.347382 sec

The time taken to reach 0  floor is 2.474358 sec

No comments:

Post a Comment