Credits for Lecturing and Authoring
Faculty Supervisor: Al Day
Some material derived from lessons authored by Dr. James Hilliard
HTML Documentation by Larry Genalo Jr.
Date Last Updated: 8/7/95
![]()
if (logic) statement
logic is a logical expression
statement is any executable C statement


if (a==b) printf("a is equal to b.\n");
Note: == is the relational operator to test for equality.

Examples:
Is x less than y?
Is pow(a,2) equal to pow(b,2)?
Is pow(x*x+y*y, 0.5) greater than 10?


![]()
Logical "AND"
Form: &&
Examples: x<y&&a>b
Interpretation: Is x<y and a>b?
x<y&&a*a==b*b
Interpretation: Is x<y AND a squared = b squared?
Logical "OR"
Form: ||
Example: a>=b||a*a<=y
Interpretation: Is a>=b or a*a>=y
Form:
if (logical condition){
___________________________
___________________________
___________________________
} else {
___________________________
___________________________
}
