Semester : S1 and S2
Subject : Computer Programming
Year : 2018
Term : MARCH
Branch : BIOTECHNOLOGY
Scheme : 2015 Full Time
Course Code : CS 100
Page:30
Enter an integer: -2 You
entered -2.
The if statement is easy.
if...else statement
The if...else statement executes some code if the test expression is true (nonzero) and some other code
if the test expression is false (0). Syntax of if...else if (testExpression) {
// codes inside the body of if
}
else {
// codes inside the body of else
}
If test expression is true, codes inside the body of if statement is executed and,
codes inside the body of else statement is skipped.
If test expression 15 false, codes inside the body of else statementis executed and,
codes inside the body of if statement is skipped
#include
main()
{
int number; _ printf("Enter an
integer: "}; scanf("%d",&number);
// True if remainder isO (ന്ധ == 0)
printf("%d is an even integer.",number); — else
printf("%d is an odd integer.",number); return 0;
}
Output
Enter an integer: 7
7 is an odd integer