If...else and if...else...if is a conditional statements which help you to make a decision based on certain conditions. For example: if a user inputs valid user name and password to login to his laptop, then he will be able to login else not.
If condition returns true then the statements inside the body of “if” are executed and the statements inside body of “else” are skipped. If condition returns false then the statements inside the body of “if” are skipped and the statements in “else” are executed.
Learn by Examples:
Examples are better than 1000 words. Examples are often easier to understand than text explanations.
C language supports three variants of if statement.
Required knowledge-
C Input instruction | C Output instruction | C Variables | C Data types | C if...else statement | C Relational operator | C Logical operator | C Arithmetic operator
Here is the list of practice programs and it's solutions based on if-else and ladder if else:
- 1) Write a C program to check whether a given number is even or odd.
- 2) Write a C program to find maximum between two numbers.
- 3) Write a C program to find maximum among three numbers.
- 4) Write a C program to check divisibility of a given number.
- 5) Write a C program to check whether a number is positive, negative, or zero.
And Many more to be updated soon...
0 Comments:
Post a Comment
Please don't enter any spam link in the comment box.