Operator |
Meaning |
---|---|
A > B |
True ( 1 ) if A is greater than B, false ( 0 ) otherwise |
A < B |
True ( 1 ) if A is less than B, false ( 0 ) otherwise |
A >= B |
True ( 1 ) if A is greater than or equal to B, false ( 0 ) otherwise |
A <= B |
True ( 1 ) if A is less than or equal to B, false ( 0 ) otherwise |
A == B |
True ( 1 ) if A is exactly equal to B, false ( 0 ) otherwise |
A != B |
True ( 1 ) if A is not equal to B, false ( 0 ) otherwise |
Operator |
Meaning |
---|---|
A && B |
A AND B - True ( 1 ) if A is true AND B is also true, false ( 0 ) otherwise |
A | | B |
A OR B - True ( 1 ) if A is true OR B is true, false ( 0 ) otherwise |
! A |
NOT A - True ( 1 ) if A is false ( 0 ), false ( 0 ) if A is true ( non-zero ). |
int year; bool leap_year; leap_year = ( ( ( ( year % 4 ) == 0 ) && ( ( year % 100 ) != 0 ) ) || ( ( year % 400 ) == 0 ) ); // Or equivalently: leap_year = (( !( year % 4 ) && (year % 100)) || !( year % 400 ));
if( condition ) { BB; } (more code) |
![]() |
void give_feedback(int studentid) { float perc = calculate_grade(studentid); if (perc >= 90) { printf("Great job!\n"); } printf("Current class percentage: %f\n",perc); } |
![]() |
If the condition is true, the BB will execute and then continue with code after the close curly brace. Otherwise, it will skip over BB and go directly to the code after the curly brace.
When you want something to happen in a special case. Otherwise, you do the normal thing.