#include <stdio.h>
#include <math.h>
void main()
{
int tim_intrval, counter,time;
float accl, distance=0, velos;
clrscr();
printf("PROGRAM FOR CALC TOTAL DISTANCE TRAVELED BY A VECHIAL");
printf("\nNO OF TIME INTERVALS : ");
scanf("%d",&tim_intrval);
for(counter = 1; counter <= tim_intrval; counter++)
{
printf("\nAT T%d TIME(sec) : ",counter);
scanf("%d",&time);
printf("\tVELOCITY AT %d sec (m/sec) : ",time);
scanf("%f",&velos);
printf("\tACCLERATION AT %d sec (m/sec^2): ",time);
scanf("%f",&accl);
distance += (velos*time + (accl*pow(time,2))/2);
}
printf("\nTOTAL DISTANCE TRAVELLED BY VEHICLE IN %d INTERVALS OF TIME : %f",tim_intrval,distance);
getch();
}
/*
Output:
PROGRAM FOR CALC TOTAL DISTANCE TRAVELED BY A VECHIAL
NO OF TIME INTERVALS : 4
AT T1 TIME(sec) : 1
VELOCITY AT 1 sec (m/sec) : 2
ACCLERATION AT 1 sec (m/sec^2): 3
AT T2 TIME(sec) : 4
VELOCITY AT 4 sec (m/sec) : 5
ACCLERATION AT 4 sec (m/sec^2): 6
AT T3 TIME(sec) : 7
VELOCITY AT 7 sec (m/sec) : 8
ACCLERATION AT 7 sec (m/sec^2): 8
AT T4 TIME(sec) : 9
VELOCITY AT 9 sec (m/sec) : 9
ACCLERATION AT 9 sec (m/sec^2): 0
TOTAL DISTANCE TRAVELLED BY VEHICLE IN 4 INTERVALS OF TIME : 404.500000
*/
No comments:
Post a Comment