Please help with making my program loop back to the beginning

Hey guys I have been trying to get my program to loop back to the beginning but I cant get it done. Please help

#include <iostream> //Libraries to be included
#include <string>
#include <sstream>
#include <math.h>
using namespace std; //All the elements of the standard C++ library are declared

char option;

float degrees;




int main()
{
string mystr; //declares a string object with a value
cout << "What's your name? "; //This line is a C++ statement
getline (cin, mystr); //Get lines from the standard input (cin) into a string object (mystr)
cout << "Hello " << mystr << ".\n";
system ( "pause" );

cout << "Press 1 or 2 to convert From :" << endl;

cout << "[1] Celsius to Fahrenheit" << endl;

cout << "[2] Fahrenheit to Celsius" << endl;


cin >> option;


if (option == '1')

{

cout << "Please enter the number of Celsius Degrees:" << endl;

cin >> degrees;

float fahren = (degrees * 1.8f) + 32;

cout << degrees << " degrees Celsius is " << fahren << " degrees Fahrenheit" << endl;

}

else

{

cout << "Please enter the number of Fahrenheit degrees" << endl;

cin >> degrees;

float celsius = (degrees - 32) / 1.8f;

cout << degrees << " degrees Fahrenheit is " << celsius << "degrees Celsius" << endl;

system ("pause");


}

return 0;

}

please next time put your code into code-syntax

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream> //Libraries to be included
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
//All the elements of the standard C++ library are declared

int main() {
	string mystr; //declares a string object with a value
	int option = -1;

	float degrees;
	while (option != 0) {
		cout << "What's your name? "; //This line is a C++ statement
		getline(cin, mystr); //Get lines from the standard input (cin) into a string object (mystr)
		cout << "Hello " << mystr << ".\n";
		system("pause");

		cout << "Press 1 or 2 to convert From :" << endl;

		cout << "[1] Celsius to Fahrenheit" << endl;

		cout << "[2] Fahrenheit to Celsius" << endl;
		cout << "[0] to exit" << endl;

		cin >> option;

		if (option == 1)

		{

			cout << "Please enter the number of Celsius Degrees:" << endl;

			cin >> degrees;

			float fahren = (degrees * 1.8f) + 32;

			cout << degrees << " degrees Celsius is " << fahren
					<< " degrees Fahrenheit" << endl;

		}

		else if (option == 2)

		{

			cout << "Please enter the number of Fahrenheit degrees" << endl;

			cin >> degrees;

			float celsius = (degrees - 32) / 1.8f;

			cout << degrees << " degrees Fahrenheit is " << celsius
					<< "degrees Celsius" << endl;

			system("pause");

		} else {
			//some log indicating -> invalide input
		}
	}

	return 0;

}
Topic archived. No new replies allowed.