If Else Practice Problems

3 min read ·

Problem 1: Check Even or Odd

Write a program to check whether a number is even or odd.

Problem 2: Check Positive, Negative, or Zero

Determine whether a number is positive, negative, or zero.

Problem 3: Voting Eligibility

Check if a person is eligible to vote based on age.

Problem 4: Find the Greatest of Two Numbers


Problem 5: Pass or Fail

Check whether a student has passed or failed.

Problem 6: Login Validation

Validate username and password.

Problem 7: Check Leap Year


Problem 8: Electricity Bill Category

Categorize electricity usage based on units consumed.

Problem 9: Number in Range or Not

Check if a number lies between 1 and 100.

Problem 10: ATM Withdrawal Check


Practice Set

Practice Task
  1. Check whether a number is divisible by 5
  2. Compare three numbers and print the greatest
  3. Create a simple calculator using if–else
  4. Check whether a character is a vowel or consonant
  5. Validate age for movie ticket pricing