Why is this not working?

May 31, 2015 at 3:43pm
So I just started learning c++ and i just tried making a simple adding calculator. When I run it it says there is an unexpected ; before the int. What is wrong with the code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  #include <iostream>
using namespace std

int main()
{
    int x;
    int y;
  cout << "Type  in a number you want to be added!" << endl;
  cin >> x;
  cin.ignore()
  cout << "And another!" << endl;
  cin >> y;
  cin.ignore()
  int sum = x + y;
  cout << "The sum is" << sum << "!" << endl;
  return 0;
}
May 31, 2015 at 3:50pm
you are missing semi-colons on lines 2, 10 and 13.
May 31, 2015 at 3:51pm
closed account (yR9wb7Xj)
You do not need the cin.ignore atleast that's what I think. Anyways you are missing semicolon for using namespace std; and as well for your cin.ignore(); It should work fine.
May 31, 2015 at 3:52pm
You're missing three semicolons.

One after using namespace std and another after both of your (unnecessary) ignores
May 31, 2015 at 3:53pm
There are actually multiple errors:

1.) You forgot to put a semicolon at the end of using namespace std

2.) Oh, and 3.)
You forgot to put another semicolon after the two cin.ignore()
May 31, 2015 at 4:25pm
Thank you for the help
Topic archived. No new replies allowed.