Need help, switch function.

I wrote this code, and somehow it didn't work, please help me fix it

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
  // this is switch practice
#include <iostream>
using namespace std;
#define PI 3.14159
#include <string>
int main ()
{
	int x;
	unsigned long a,b,c,d,e,f;
	string degree, radian, meter;
	cout<<"What you wanna do?\n1) Convert from degree to radian\n2) Convert from radian to degree\n3) Convert from inch to meter\n4) Quit"<<endl;
	cin>>x;
	switch (x)
	{
	
		case 1:
			cout<<"Please enter the degree: ";
			cin>>a;
			radian=a*PI/180;
			cout<<"The result is: "<<radian;
			break;
		case 2:
			cout<<"Please enter the radian: ";
			cin>>b;
			degree=b*180/PI;
			cout<<"The result is: "<<degree;
			break;
		case 3:
			cout<<"Please enter the inch(es): ";
			cin>>c;
			meter=c*0.0254;
			cout<<"The result is: "<<meter;
			break;
		default:
			cout<<"Press enter to quit";
			break;
	}
	return 0;
}
Hi slimfit,

use float instead of string and unsigned long.
Topic archived. No new replies allowed.