20 IF–ELSE Statement Questions in C++ with Answers (Beginner Friendly)
Introduction
The if–else statement is one of the most important decision-making statements in C++ programming.
It allows a program to execute different blocks of code based on a condition.
If you are a beginner, preparing for:
-
College exams
-
Coding interviews
-
Competitive programming
then practicing if–else questions is very important.
👉 In this article, you will learn 20 important if–else statement questions in C++ with answers and examples.
What is IF–ELSE Statement in C++?
The if–else statement is used to check conditions.
Syntax:
20 Important IF–ELSE Statement Questions in C++
1. Program to check whether a number is even or odd
✅ Output: Even
2. Check whether a number is positive, negative or zero
✅ Output: Negative
3. Find the greatest of two numbers
✅ Output: 20
4. Find the greatest of three numbers
✅ Output: 9
5. Check voting eligibility
✅ Output: Not Eligible
6. Check pass or fail
✅ Output: Fail
7. Program to check leap year
✅ Output: Leap Year
8. Check whether a character is vowel or consonant
✅ Output: Vowel
9. Check whether a number is divisible by 5
✅ Output: Divisible by 5
10. Check profit or loss
✅ Output: Loss
11. Check whether a character is an alphabet
✅ Output: Not an Alphabet
12. Check whether a number is zero
✅ Output: Zero
13. Check temperature condition
✅ Output: Hot Weather
14. Check eligibility for driving license
✅ Output: Eligible for Driving License
15. Check whether number is divisible by 3 and 7
✅ Output: Divisible by 3 and 7
16. Program to find grade
✅ Output: Grade B
17. Check whether a character is uppercase
✅ Output: Uppercase Letter
18. Check bonus eligibility
✅ Output: No Bonus
19. Check whether number is a 3-digit number
✅ Output: Three Digit Number
20. Simple login validation
✅ Output: Access Granted
Advantages of IF–ELSE Statement
-
Easy to understand
-
Controls program flow
-
Used in real-life decision making
-
Very important for interviews
Conclusion
The if–else statement in C++ is a core concept that every beginner must master.
Practicing these 20 if–else questions with answers will help you build logic and confidence.

Comments
Post a Comment