LiveWire Peer Support Network

Printable Version of Topic "C++ HELP!"

- LiveWire Teen Forums & College Forums (http://www.golivewire.com)
-- (http://www.golivewire.com/forums/support-technical.html)
--- Programming & Application Development (http://www.golivewire.com/forums/forum-211-s-0.html)
---- C++ HELP! (http://www.golivewire.com/forums/peer-yaeoeib-support-a.html)


-- Posted by Eric 2009 at 6:53 pm on July 12, 2008

#include
using namespace std;
const double m_to_k = 1.609;
inline int convert(int mi) {return (mi * m_to_k);}

int main(){

int miles;

do{
cout<<"Input your miles: ";
cin >>miles;
if (miles == 1.609){
cout<<"1 mile." < }
else{
cout <<"\nDistance is " << convert(miles) << " km." < }
}while(miles > 0) ;
return(0);
}

when i input 1.609 i get an infitine loop that continues until i manually close the program


-- Posted by Eric 2009 at 6:54 pm on July 12, 2008

NEVERMIND!!!!


-- Posted by in loveeex3 at 6:55 pm on July 12, 2008

heehee nerd


-- Posted by HideOrSeek at 6:59 pm on July 12, 2008

"if (miles == 1.609){
cout<<"1 mile." < }
else{
cout <<"\nDistance is " << convert(miles) << " km." < }
}while(miles > 0) ;
return(0);
} "

What if you get rid of the If, and instead converting in Else, just Convert whatever the user inputs?

Besides, why are you using a loop?
I think you just need to do the procedure once, you could use a loop when asking the user if he'd like to convert a different measure...
Hmn?


www.golivewire.com