Just isn't working.

For some reason everytime I run the program and type any other option besides "1", it just runs option "1" anyways. =/

Can anyone help me out?
Now it was a little more simplistic before, but maybe something very simple slipped my mind.

Code:

#include <iostream>

using namespace std;

int main()
{

int choice;

do
{
cout << "~Please pick an option~" << endl;
cout << "1) Fahrenheit to Celcius." << endl;
cout << "2) Celcius to Fahrenheit." << endl;

cin >> choice;
if(choice = 1)
{
cout << endl << "Please insert degrees in fahrenheit: " << endl;
double f;
cin >> f;
double conversion1 = ((f-32)*5)/9;
cout << "Your degrees in celcius is " << conversion1 << "." << endl;
}
else if(choice = 2)
{
cout << endl << "Please insert degrees in celcius: " << endl;
double c;
cin >> c;
double conversion2 = ((c*9)/5)+32;
cout << "Your degrees in fahrenheit is " << conversion2 << "." << endl;
}
else
cout << "Your inserted the incorrect option";
}
while(choice != 1 || choice != 2);
system("pause");
return 0;
}
closed account (z05DSL3A)
at first glance,

if(choice = 1) should be if(choice == 1) (same for the others).


Last edited on
xD omg i can't believe that slipped passed me, one of the easiest things of all, and it stumped me lol. thanks wolf, really appreciate it lol. :)
Topic archived. No new replies allowed.