so im trying to write this program that converts Fahrenheit to Celsius and vice versa but im gettin an infinate loop at the menu. i go to select the number that i want and it just displays the menu again, i though i was doin it right?

#include <iostream>	//for cin and cout
#include <iomanip>  
#include <cmath>

using namespace std;

void main()
{
	double C,	//Celsius
                       F;//Fahrenheit

	int choice;	//Number for choice

	#define cls   ("cls")	// clear system
	#define pause ("pause")	// pause system

	do
	{
		
		cout << "Select one the the following options: \n\n";
			cout << "  1. Temperature conversion from Fahrenheit to Celsius: \n\n"
				 << "  2. Temperature conversion from Celsius to Fahrenheit: \n\n"
				 << "  3. Quit the program now: \n" << endl;

		cin >> choice;
		
		switch (choice)
		{
		case '1': cout << "Enter the degrees in Fahrenheit: \n\n";
				  cin >> F;
				  
				  C = 5 / 9 * ( F - 32 );

				  cout << "The conversion is: " << C << endl;
				  break;

		case '2': cout << "Enter the degrees in Celsius: \n\n";
				  cin >> C;

				  F = 9 * C / 5 + 32;

				  cout << "The conversion is: " << F << endl;
				  break;

		case '3': cout << "Program closed" << endl;
				  break;
		}
	}
	while (choice != '3');
}

<< moderator edit: added [code][/code] tags >>

Since choice is an int, compare it with 1, 2, and 3 -- not with characters '1', '2', and '3'.

oh geez i never though about thanks makes sense now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.