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>
usingnamespace 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;
}
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.