7. Write a C program to find out distance travelled by the equation d = ut + at^2
#include<stdio.h>
#include<conio.h>
#include<math.h> //Here we are using math.h header file because of the function 'pow' .It only works under the header file math.h
void main()
{
float d,u,a,t;
printf("u=");
scanf("%f",&u);
printf("a=");
scanf("%f",&a);
printf("t=");
scanf("%f",&t);
d=(a*t)+(a*pow(t,2));
printf("distance=%f",d);
getch();
}
#OUTPUT:
#include<conio.h>
#include<math.h> //Here we are using math.h header file because of the function 'pow' .It only works under the header file math.h
void main()
{
float d,u,a,t;
printf("u=");
scanf("%f",&u);
printf("a=");
scanf("%f",&a);
printf("t=");
scanf("%f",&t);
d=(a*t)+(a*pow(t,2));
printf("distance=%f",d);
getch();
}
#OUTPUT:
Comments
Post a Comment