#include <iostream>
#include <cmath>
using namespace std;

const float G = 32.17;
// function declaration 
float caltime ( float,float, float );
float calheight ( float,float,float);
// main function
int main()
{
    
float theta,  cotheta,  sitheta, distance,  velocity,  time, height;
cout << " Input the angle of elevation : " << endl;
cin >> theta;
cotheta = cos(theta);
sitheta = sin (theta);
cout << " Input the distance : " << endl ;
cin >> distance;
//use function 
time = caltime ( distance,velocity, cotheta);
height = calheight ( velocity, sitheta, time) ;
cout << " The flight will reach in the target within"<< time << "second " << endl;
cout << " The height will be " << height << "ft above the ground" << endl;
system ("pause");
return 0;
}

float caltime ( float x, float y, float z)
{
      float timefind;
      timefind = x/(y * z);
      return timefind;
      }
float calheight (float a,float b, float c)
{
      float heightfind;
      heightfind = ( a * b * c - (G * c*c /2)) ;
      return heightfind;
      }

Input the angle of elevation :
0.3
Input the distance :
1000
The flight will reach in the target within1.#INFsecond
The height will be -1.#INDft above the ground
Press any key to continue . . .

the result should not be like that, rite? how can I fix it

No, velocity is not initialized. That would seem to be a value the user must enter.

Also, in your prompts to the user, specify the angle is in radians, not degrees.

This article has been dead for over six months. Start a new discussion instead.