#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

Determining velocity value..

Check the value of time
It's not initialized

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.