Error: Expected unqualified-id fix

I Don't know what's wrong with this. I've tried a lot of things, but never got it to work. Can anybody help me?

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

int main();
int Select, num1, num2, sum, diff, pro, quo, p, m, d, s;
;{

  cout<<"Please enter number 1\t";
  cin>>num1;
  cout<<"\nPlease enter number 2\t";
  cin>>num2;
   cout<<"\nFor Addition, press p";
  cout<<"\nFor Subtraction, press s";
  cout<<"\nFor Multiplcation, press m";
  cout<<"\nFor Division, press d";
  cin>>select;
    if(select==p)
  {
    sum = num1 + num2;
    cout<<"The awnser is"<<sum<<".";
  }
  else if (select==s)
  {
    diff = num1 - num2;
    cout<<"The awnser is"<<diff<<".";
  }
  else if (select==m)
  {
    pro = num1 * num2;
    cout<<"The awnser is"<<pro<<".";
  }
  else if (select==d)
  {
    quo = num1 / num2
    cout<<"The awnser is"<<quo<<".";
  }


}
Start with something like:

1
2
3
4
5
6
7
#include <iostream>

int main()
{

    std::cout << "Hello Boxtopy\n";
}


Once you get this to compile correctly replace the std::cout statement a little bit at a time. Remember Compile early, compile often, and always fix all warnings and errors pointed out by your compiler before you continue.



int main(); <------- that ; tells the c++ compiler that somewhere later you will declare main.
that is not what you wanted and the ; here is incorrect.
you also have an extra but harmless ; on line 6.
you also have a bunch of ints before main's body which is also wrong.

the format is, as shown above,
int main()
{ //begin main
things
} // end main

not int main();
and not
int main()
things //not here
{//begin

you should also know that integer division produces zero for 2/3 and 1 for 5/6 etc so you may want to use a floating point type there.

Last edited on
Topic archived. No new replies allowed.