Flight Seating arrangements

uhm, I know that i should be doing my own homework , but can anyone tell me whats wrong in this part.(This is just a part of the If else if statements im using )
The col is always equal 0.

 
 

if(x==29 || 33 || 37 || 41 || 45 || 49 || 53 || 57 || 61 || 65 || 69 || 73 || 77)
col=0;
else if(x==30 || 34 || 38 || 42 || 46 || 50 || 54 || 58 || 62 || 66 || 70 || 74 || 78)
col=1;
else if(x==31 || 35 || 39 || 43 || 47 || 51 || 55 || 59 || 63 || 67 || 71 || 75 || 79)
col=2;
else if(x==32 || 36 || 40 || 44 || 48 || 52 || 56 || 60 || 64 || 68 || 72 || 76 || 80)
col=3;
Last edited on
You must check each of the numbers with the double equal sign, as in..

if(x==29 || x==33 || x==37 ||x== 41 || x==45 || x==49 || x==53 || x==57 || x==61 || x==65 || x==69 || x==73 || x==77)
Some languages MAY let you do the checking the way you have it, but C++ is not one of them.
Thanks !
It looks like the expression could be simplified:
1
2
3
if (x >= 29){
    col = (x - 29) % 4;
}
Registered users can post here. Sign in or register to post.