Beginner programming class cant figure out error

Hello. I am taking my first c++ class and our project is to practice using user defined functions by writing a program that converts polar to rectangular and vice versa. This is what i have and im getting an odd error:

The error i get says "expected unqualified-id before 'switch'"

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
//	Preprocesor Directives
using namespace std;
#include<iostream>
#include<iomanip>
#include<cmath>

//	UDF declerations
void readit(float&, float&, float&, float&, float&);
float calcit(float, float, float, float);
void writeit(float, float, float, float);

//	Delcerationn and defenition of the main
int main()
{
	float mag, angl, x, y, num;
	
	readit(mag, angl, x, y, num);
	calcit(mag, angl, x, y);
	writeit(mag, angl, x, y);
	return 0;
}
//	if you pass by value you dont plan on bringing it back


//	Defenition of UDF readit
void readit(float& mag, float& angl, float& x, float& y, float& num)
{
	
	cout << "Please enter an action:" << endl;
	cout << "1 for polar to rectangular calculator" << endl;
	cout << "2 for rectangular to polar calculator" << endl;
	cout << "Or any other number to quit" << endl;
	cin  >> num;

	system("CLS");
}
	switch(num)
	{
		case 1:
			cout << "Please enter the magnitude and angle (in degrees)" << endl;
			cin  >> mag >> angl;
	
	float calcit(float mag, float angl, float x, float y)
{
	
	x = mag * cos(angl * (M_PI / 180.0));
	y = mag * sin(angl * (M_PI / 180.0));
		
}

void writeit(float mag, float angl, float x, float y)
{
	cout << "With a given magnitude of " << mag << " and an angle of " << angl << "degrees\n"
		 << "The rectangular conversions are x equals " << x << " and y equals" << y; 
}
	
return 0;
}
Well for one you have a function inside your {} for switch. Line 51
Your switch is outside your main.
It may just be a matter of moving your {}'s around.
Topic archived. No new replies allowed.