Update: I now managed to make the code execute. The only problem now is that if I input "1", the whole code executes instead of just the body inside of the if statement.
I'm also try to get the code to loop as many times as the user wants.
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
int num;
cin >>num;
if (num == 1)
{
cout<<"1 works";
}
else
(num == 2); // Statement that does nothing
{ // This block has nothing to do with the 'else' above
cout<<"2 works"<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
So change the else to a elseif and remove the semicolon after that line and you'll have what you what.