LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 329 users online 225696 members 400 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
acausedelle
And I swear it's the last time, and I swear it's my l...
Mood: Wishful
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
2 online / 28 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Adding Reply

Quoting Post
Archived Topic: It will not be bumped to the top of the forum.
Topic C++ HELP!
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
Eric 2009 Posted at 6:53 pm on July 12, 2008
#include <iostream>
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." <<endl;
}
else{
cout <<"\nDistance is " << convert(miles) << " km." <<endl;
}
}while(miles > 0) ;
return(0);
}

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

Replies
HideOrSeek Posted at 6:59 pm on July 12, 2008
"if (miles == 1.609){
cout<<"1 mile." <<endl;
}
else{
cout <<"\nDistance is " << convert(miles) << " km." <<endl;
}
}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?

in loveeex3 Posted at 6:55 pm on July 12, 2008
heehee nerd
Eric 2009 Posted at 6:54 pm on July 12, 2008
NEVERMIND!!!!
All 3 previous replies displayed.