Hi, so i was working in c++ on a little practice program and i keep getting the error
"Expected ';' before 'cout'. someone help please? here's the code so far:
#include <iostream>
using namespace std;
int main()
{
int age;
cout << "Hello. please enter your age.!" << endl;
cin >> age;
if ( age < 20 )
cout << "you are quite young and have a lot to learn" << endl;
else if ( age > 20 ) ( age < 40 )
cout << "you are finally out in the real world. But your still young" << endl;
else if ( age > 40 ) ( age < 60 )
cout << "Your middle age and have enough life xperience to educate the youth. Don't let it go to waste" << endl;
else ( age > 60 ) ( age < 80 )
cout << "Dude, your old. Enough said" << endl;
#include <iostream>
using namespace std;
int main()
{
int age;
cout << "Hello. please enter your age.!" << endl;
cin >> age;
if ( age < 20 )
cout << "you are quite young and have a lot to learn" << endl;
else if (( age > 20 ) && ( age < 40 ))
cout << "you are finally out in the real world. But your still young" << endl;
else if (( age > 40 ) && ( age < 60 ))
cout << "Your middle age and have enough life xperience to educate the youth. Don't let it go to waste" << endl;
else {(( age > 60 ) && ( age < 80 ));
cout << "Dude, your old. Enough said" << endl;
}
return 0;
}
Also, another problem is still with your arguments. The way you have it written, if someones age is 40 or 60, nothing is going to happen. Try using <= and >= which is greater than or equal to, and less than or equal to. It will include those numbers.
On the subject of math, do a little reading on the difference between == and =
They are two totally separate things and will drive you crazy if you misuse them on a program.
= is used for assigning value to something
For example, if you have a value that will change, such as figuring out weekly pay, your code is this:
pay = hours * wage
So pay will adjust according to how you adjust your hours and wages in the program.
== means equal to
So pretend we have a variable called n and you have a line which is
if (n + 50 == 100)
That will mean that if n + 50 equals 100, then everything in your if statement will happen.