You are viewing our Forum Archives. To view or take place in current topics click here.
need help, cant get my source code to compile
Posted:
need help, cant get my source code to compilePosted:
Status: Offline
Joined: Sep 05, 201212Year Member
Posts: 384
Reputation Power: 14
Status: Offline
Joined: Sep 05, 201212Year Member
Posts: 384
Reputation Power: 14
i seem to be getting
error: expected primary expression before '||'
and
error 'else' without a previous if
can somebody please help me
thanks in advance
#include <iostream>
using namespace std;
int main()
{ int x = 8;
int y = 3;
int a = 8;
int number;
if ((x > 5 ) && (y < 5)) || (a > 5);
{cout << "x is > than 5,y is < than 5, a is > than 5 \n";
else
return main;
}
error: expected primary expression before '||'
and
error 'else' without a previous if
can somebody please help me
thanks in advance
#include <iostream>
using namespace std;
int main()
{ int x = 8;
int y = 3;
int a = 8;
int number;
if ((x > 5 ) && (y < 5)) || (a > 5);
{cout << "x is > than 5,y is < than 5, a is > than 5 \n";
else
return main;
}
#2. Posted:
Status: Offline
Joined: Jan 01, 201114Year Member
Posts: 1,957
Reputation Power: 401
Your IF Statement syntax is incorrect
if (condition) {
statements
} else {
statements
}
this is how it should look
if (((x > 5 ) && (y < 5)) || (a > 5))
{
cout << "x is > than 5,y is < than 5, a is > than 5 \n";
}
else (if you have no else clause then this can be removed)
if (condition) {
statements
} else {
statements
}
this is how it should look
if (((x > 5 ) && (y < 5)) || (a > 5))
{
cout << "x is > than 5,y is < than 5, a is > than 5 \n";
}
else (if you have no else clause then this can be removed)
- 1useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.