Im getting an error on visual studio that the left brace on the very top is unmatched at the end of the file. I am so confused and dont know what its talking about cause i have the ending brace at the end.
#include <iostream>
usingnamespace std;
int main()
{
int choice1, choice2, hours;
constint UNDERGRAD = 1;
constint GRAD = 2;
constint YES = 1;
constint NO = 2;
cout << " Thank you for your interest in our project." << endl;
cout << "Please answer the following questions by choosing the option that describes you." << endl;
cout << "What is your academic status:" << endl;
cout << "1. Undergraduate" << endl;
cout << "2.Graduate" << endl;
cout << "enter 1 or 2" << endl;
cin >> choice1;
if (choice1 == UNDERGRAD)
{
cout << "How many hours of programming have you taken?" << endl;
cin >> hours;
if (hours >= 12)
{
cout << "Congratulations, you are elgible to work on this project." << endl;
}
else {
cout << "Unfortunately you are not eligible to participate in the project." << endl;
cout << "Thanks for your time" << endl;
}
cin.get();
cin.get();
cin.get();
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int choice1, choice2, hours;
constint UNDERGRAD = 1;
constint GRAD = 2;
constint YES = 1;
constint NO = 2;
cout << " Thank you for your interest in our project." << endl;
cout << "Please answer the following questions by choosing the option that describes you." << endl;
cout << "What is your academic status:" << endl;
cout << "1. Undergraduate" << endl;
cout << "2.Graduate" << endl;
cout << "enter 1 or 2" << endl;
cin >> choice1;
if (choice1 == UNDERGRAD)
{
cout << "How many hours of programming have you taken?" << endl;
cin >> hours;
if (hours >= 12)
{
cout << "Congratulations, you are elgible to work on this project." << endl;
}
else {
cout << "Unfortunately you are not eligible to participate in the project." << endl;
cout << "Thanks for your time" << endl;
}
cin.get();
cin.get();
cin.get();
return 0;
}
This is pretty good advice for any kind of parenthetical pair. Modern IDEs will typically do it for you, even. If you type an open parenthesis, for example, it will automatically add a close parenthesis after the cursor insertion point:
Don't indent your code.
That superfluous white space is not understood by the compiler and so it's discarded.
Moreover, it may lead to confusion, as it happened in this case, because people do assign it a meaning. Then you have that dangerous situation where people and the compiler understand different things from the source code.
In order to avoid that, the solution is simple.
Don't indent your code, let your IDE do it for you.