Saturday, March 6, 2021

C program to calculate distance travelled by a body.

 

1.     Write a C program to calculate distance travelled by a body.

 

#include<stdio.h>

#include<conio.h>

int main()

{

float u, a, s;

int t;

printf("Enter initial velocity: ");

scanf("%f", &u);

printf("Enter acceleration: ");

scanf("%f", &a);

printf("Enter time: ");

scanf("%d", &t);

s=(u*t)+(a*t*t)/2;

printf("Distance travelled by body= %.2f", s);

 

return 0;

}

No comments:

Post a Comment