void function "expected initializer before void"

I'm making a program for class and I keep getting this annoying error. I literally have no idea why it's showing up or what the heck it means. It's a little frustrating...VERY.

Here is the code and it keeps telling me that "main.cpp:7:1: error: expected initializer before 'void' void A_Rectangle()" Any ideas?
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 #include <iostream>
#include <iomanip>
using namespace std;

void Menu()

void A_Rectangle()

void A_Circle()

void A_Triangle()



int main()
{
int Input;
Menu();
cin >> Input;
    while(Input ==! 4)
    {
    if (Input == 1)
    A_Rectangle();
    else if (Input == 2)
    A_Circle();
    else if (Input == 3)
    A_Triangle();
    else
    {
    cout << "invalid try again";
    cin >>  Input;
    }
    
system("pause");
return 0; 
    
    
}





void Menu()
{
cout << "\n Would you like to know the Area of a rectangle?  :: press 1\n";
cout << "\n Would you like to know the Area of a circle?  :: press 2\n";
cout << "\n Would you like to know the Area of a triangle?  :: press 3\n";     
cout << "\n Would you like to exit?  :: press 4\n";     
     
     
     
}

void A_Rectangle()
{
 cout << "\nenter the length and the width\n";
 
 int length;
 int width;
 
 cin >> length >> width;
 
     while (length >= 0 || width >= 0)
     {
     cout << "\nthe measurements cannot be 0 or negative\n" << "please try again";
     cin >> length >> width;
     }
 
 cout << "\nThe area is  " << length*width;
 
}

void A_Circle()
{
 int radius;
 cout << "enter the radius";    
 cin >> radius;
 
        while (radius >= 0)
        {
        cout << "\nthe measurements cannot be 0 or negative\n" << "please try again";
         cin >> radius;      
        }
 
 
 
 cout << 2*3.14*radius;
     
}

void A_Triangle()
{
int base;
int height;   
cout << "\nenter the base and the height\n"

     while (base >= 0 || height >= 0)
        {
        cout << "\nthe measurements cannot be 0 or negative\n" << "please try again";
         cin >> base >> height;      
        }

cout << .5*base*height;
}  
     
     
     
Sometimes the error occurs before the indicated line. In this case, your first error is on line 5. You need semicolons after all your function definitions.
I thought you didnt have to put semicolons after the function prototypes. Plus after I do this it keeps telling me "a function-definition is not allowed here before '{' token"
Last edited on
Well, you do need semicolons. Read the error you get after adding in the semicolons; the cpp.sh compiler says it's on line 46, but actually, it's on line 33, you're missing a }. And while we're at it, you're also missing a semicolon on 96.
Last edited on
duplicate; deleted
Last edited on
ok I also noticed that when I go to the while loop it just exits me out of the program? without running the runctions.
line 20 s/b
 
while(Input != 4)
OK OK OK WOW... I made quite a few mistakes...but hey it works now thanks for the help :D
Topic archived. No new replies allowed.