Programming for Problem Solving

GTU Practical 7

7. Write a C program to find out the distance travelled by the equation d = ut + at^2
#include<stdio.h>  ( this applies in the given code )

#include

int main()
{
float u,a,d;
int t;

printf(“\nEnter the value of a : “);
scanf(“%f”,&a);

printf(“\nEnter the value of u : “);
scanf(“%f”,&u);

printf(“\nEnter the value of t : “);
scanf(“%d”,&t);

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

printf(“\n The Distance : %f”,d);

return 0;
}

OUTPUT

Enter the value of a : 10

Enter the value of u : 20

Enter the value of t : 5

The Distance : 225.000000

GTU STUDY