I'm trying to compile this sample program from AntiRTFM's C++ tutorials and it gives me an error stating that it cannot perform an else statement without a previous if. But the if is there. Please help
#include <iostream>
usingnamespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv)
{
int theNumber = 76;
int Playersguess = 50;
if (Playersguess == theNumber)
cout << "They are equal";
cout << endl;
else
cout << "Not equal";
cout << endl;
return 0;
}.
#include <iostream>
usingnamespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv)
{
int theNumber = 76;
int Playersguess = 50;
if (Playersguess == theNumber)
{
cout << "They are equal";
cout << endl;
}
else
{
cout << "Not equal";
cout << endl;
}
return 0;
}
You can use any editor you want, syntax won't change. Just read that article on control structures. This website provides great documentation on C++ syntax, reading them would help a lot. http://www.cplusplus.com/doc/tutorial/control/