Saturday, August 21, 2010

PROJECTILE MOTION

0 comments
SOURCE CODE:


/*To determine the maximum height,time of flight and horizontal range of a projectile motion*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float u,g=9.8,theta,T,R,h,H,rtheta;
clrscr();
printf("Enter the velocity:");
scanf("%f",&u);
printf("\nEnter angle of prijection:");
scanf("%f",&theta);
rtheta=3.1415*theta/180;
H=u*u/(2*g);
T=2*u*sin(rtheta)/g;
R=u*u*sin(2*rtheta);
h=H*pow(sin(rtheta),2);
printf("\n*************************THE RESULT*************************\n");
printf("\nThe maximum height is:%fm\n",H);
printf("\nThe time of flight is:%fs\n",T);
printf("\nThe horizontal range is:%fm\n",R);
printf("\nThe maximum vertical height for angle %f is:%fm\n",theta,h);
getch();
return;
}


Algorithm:

1.Start
2.Read the velocity,u
3.Read the angle,theta
4.Calculate maximum height H=u2/2g
5.Calculate the time of flight ,2usin(rtheta)/g
6.Calculate horizontal range,u2sin(2*rtheta)
7.Calculate maximum vertical height,h=H*pow(sin(rtheta),2)
8.Print maximum height,time of flight,horizontal range and vertical height.
9.Stop


Leave a Reply