#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int int_count,i,time;
float acc,dist,vel,total_dist=0;
clrscr();
printf("\nEnter the total no.of intervals to calculate the distance value");
scanf("%d",&int_count);
for(i=1;i<=int_count;i++)
{
printf("\nEnter the time(sec) travelled at interval %d",i);
scanf("%d",&time);
printf("\nEnter the current velocity of vehicle at %d interval",i);
scanf("%d",&vel);
printf("\n Enter the acceleration of vehicle at %d interval",i);
scanf("%d",&acc);
dist=(vel*time)+0.5*acc*pow(time,2);
printf("\nThe distance travelled by vehicle at interval %d is %f",i,dist);
total_dist+=dist;
}
Printf("The total distance travelled by vehicle in the specified interval time is %f",total_dist);
getch();
}
#include<conio.h>
#include<math.h>
main()
{
int int_count,i,time;
float acc,dist,vel,total_dist=0;
clrscr();
printf("\nEnter the total no.of intervals to calculate the distance value");
scanf("%d",&int_count);
for(i=1;i<=int_count;i++)
{
printf("\nEnter the time(sec) travelled at interval %d",i);
scanf("%d",&time);
printf("\nEnter the current velocity of vehicle at %d interval",i);
scanf("%d",&vel);
printf("\n Enter the acceleration of vehicle at %d interval",i);
scanf("%d",&acc);
dist=(vel*time)+0.5*acc*pow(time,2);
printf("\nThe distance travelled by vehicle at interval %d is %f",i,dist);
total_dist+=dist;
}
Printf("The total distance travelled by vehicle in the specified interval time is %f",total_dist);
getch();
}
No comments:
Post a Comment