Getting back into C++

Hey whats up guys, I have not done any programming for at least 3 years, im trying to get back into it. The problem I am having today is getting my user defined functions to work. What I would like to happen is for the user to input the values length and width for my two calculating functions and have my void function bring up a simple menu where the user can choose to see the area of a rectangle or the perimeter. Like I said I haven't done this in awhile, its probably a simple fix, will appreciate hints or feedback.

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
  #include <iostream>
using namespace std;

double areaR(double length, double width);
double perimeterR(double length, double width);
void menu();

int main()
{
	double length, width;
	cout <<"Please enter rectangles length and width." <<endl;
	cin >> length >>width;
	areaR(length,width);
	perimeterR(length, width);
	void menu();
   
   return 0;
}
double areaR(double length, double width)
{
	return length * width;
}
double perimeterR(double length, double width)
{
	return 2*(length+width);
}
void menu()
{
	char choice;
	cout <<"Welcome" <<endl;
	cout <<"Press r for area of a rectangle" <<endl;
	cout <<"Press l for perimeter of a rectangle" <<endl;
	cout <<"Press q for quit" << endl;

	cin>> choice;
    if (choice == 'r'){
	
	cout <<"Area of a rectangle =" <<areaR<<endl;
}
	else if(choice == 'l'){
	
	cout <<"Perimeter of a rectangle =" <<perimeterR<<endl;
}
	else{
	
	cout <<"Exit Menu" <<endl;
}
}

its probably a simple fix

Indeed it is!

void menu(); // You call a function by it's name, remove void
Last edited on
Wow, thanks haha
Topic archived. No new replies allowed.