``````#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, float cotheta, float sitheta, float distance, float velocity, float time, float 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 * cotheta);
return timefind;
}
float calheight (float a,float b, float c)
{
float heightfind;
heightfind = ( a * b * c - (G * c*c /2))
return heightfind;
}``````

13 C:\Documents and Settings\QuynhlNguyen\My Documents\Final\find time and height.cpp expected unqualified-id before "float"

## All 4 Replies

``````#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()
{
// here u go
float theta, /*float*/ cotheta, /*float*/ sitheta, /*float*/ distance, /*float*/ velocity, /*float*/ time,  /*float*/ 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 * cotheta);
return timefind;
}
float calheight (float a,float b, float c)
{
float heightfind;
heightfind = ( a * b * c - (G * c*c /2))
return heightfind;
}``````

I don't know what do you mean

`float theta, float cotheta` ..etc..That's wrong..Should be `float theta, cotheta` ..etc..

You can't use:

``float theta, float cotheta, float sitheta, float distance, float velocity, float time, float height;``

Instead, just put `float` once before the whole line. Like cikara21 said:

``float theta, /*float*/ cotheta, /*float*/ sitheta, /*float*/ distance, /*float*/ velocity, /*float*/ time,  /*float*/ height;``

Ah! Beaten to it! :P
Now you can mark this thread as solved!

Be a part of the DaniWeb community

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