need help find the error in my Program

my program is not working correctly
this program is suposed to find distance rate time depending on which u dont know

using namespace std;

float d(float,float);
float r(float,float);
float t(float,float);

int main()
int distance,rate,time;
cout<<"Give me The Distance , Rate , Time and put a zero for the one you do not know"<<endl;
cout<<"What is the distance"<<endl;
cout<<"What is the rate(miles)"<<endl;
cout<<"What is the time"<<endl;

if (distance=0)
else if (rate=0)
else if (time=0)

cout<<"The distance was"<< d( rate, time)<<endl;
cout<<"the rate was"<<r( distance, time)<<endl;
cout<<"the time was"<<t( distance, rate)<<endl;
return 0;

float d(float rate,float time)
return rate*time;

float t(float distance,float rate)
return distance/rate;

float r(float distance,float time)
return distance/time;
Last edited on
what is it doing wrong
why are you taking int distance,rate,time; though your function argument is in form of float..make them float...
you wrote distance=0 it's an assignment you need comparison..
so, it will be like distance==0.
oh i didnt catch that good find hitesh. stupid c and its flexibility... almost as bad as html
thanks everyone! :)
Topic archived. No new replies allowed.