my program is not working correctly

this program is suposed to find distance rate time depending on which u dont know

#include<iostream>

#include<conio.h>

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;

cin>>distance;

cout<<"What is the rate(miles)"<<endl;

cin>>rate;

cout<<"What is the time"<<endl;

cin>>time;

if (distance=0)

{

cout<<d(rate,time);

}

else if (rate=0)

{

cout<<r(distance,time);

}

else if (time=0)

{

cout<<t(distance,rate);

}

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;

_getch();

}

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;

}

this program is suposed to find distance rate time depending on which u dont know

#include<iostream>

#include<conio.h>

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;

cin>>distance;

cout<<"What is the rate(miles)"<<endl;

cin>>rate;

cout<<"What is the time"<<endl;

cin>>time;

if (distance=0)

{

cout<<d(rate,time);

}

else if (rate=0)

{

cout<<r(distance,time);

}

else if (time=0)

{

cout<<t(distance,rate);

}

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;

_getch();

}

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

why are you taking **float**..make them float...

you wrote**distance=0** it's an assignment you need comparison..

so, it will be like**distance==0**.

`int` distance,rate,time;

though your function argument is in form of you wrote

so, it will be like

oh i didnt catch that good find hitesh. stupid c and its flexibility... almost as bad as html

Topic archived. No new replies allowed.