Every time I try and build the code it says that I have a syntax error and that the end of the file was found before the left brace was matched. I am new to C++ but I have the same number of left braces as right braces in my code. Every time I try and fix the code I get the same error message. If you could help me figure out what is wrong I would much appreciate it!
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
double num, power, total;
char again;
do
{
cout << "Enter a number: ";
cin >> num;
cout << "Enter the power to raise " << num << " to: ";
cin >> power;
total = pow(num, power);
cout << "\n" << num << " to the " << power << " is " << total << "\n";
do
{
cout << "Do you want to raise another number to a power? ";
cin >> again;
if(again != 'Y' || 'y' || 'N' || 'n') {
cout << "\t" << "Please enter Y or N";
} while(again != 'Y' || 'y' || 'N' || 'n');
if(again == 'N' || 'n') cout << "Goodbye, program is terminating";
} while(again == 'Y' || 'y');
system("pause");
return 0;
}
A good code editor should be able to highlight matched braces, place the cursor on either an opening or closing brace and it will highlight the one which matches. Even without changing the formatting of the text, this can help identify such errors very quickly, in fact before you even get as far as compiling the code.