Wednesday, April 6, 2016

If-else Statement in C++

if-else statement
if statement is most commonly used with the following format:
where else part is optional.
In this case, either of the two statements are executed depending upon the value of the expression. If the expression has a non-zero value (i.e., if the expression is true), then statement1 will be executed. Otherwise (i.e., if expression is false), statement2will be executed.
Example:
Given here is a program which reads a number and then prints whether the given number is even or odd.
Note: If we divide a number by 2 and if the remainder is 0 then the number is EVEN else the number is ODD

0 comments:

Post a Comment