Pages

Visitors

Monday, 26 December 2011

Distance Calculator : Choose Time interval


To WAP To calculate the Displacement of a particle at a time t in time intervals input by the user along with initial velocity and acceleration.


CODE:

#include <stdio.h>

void main()

{
     float s,u,t,a,n,max;

     printf("Enter values of u and a and max time: ");

     scanf("%f%f%f",&u,&a,&max);

     printf("enter interval : \n");

     scanf("%f",&n);


     printf("\nTime          Distance\n");

     for(t=0;t<=max;t=t+n)

     {
        s = u*t+0.5*a*t*t;

        printf("%5.2f        %7.2f\n",t,s);
     }

     getch();
}

No comments:

Post a Comment