- Writing if, if-else, and if-else-if ladder statements
- Building nested if-else logic for multi-condition problems
- Using switch-case for menu-driven and categorized decisions
- Applying the ternary operator for compact conditional expressions
- Checking positive/negative/zero, vowels, alphabets, digits, and special characters
- Finding roots of quadratic equations and absolute values
- Calculating grades, electricity bills, BMI categories, and income tax
- Determining leap years, days of the week, and seasons by month
- Converting temperature and performing arithmetic operations based on user choice
Conditional statements are the decision-making backbone of every C program. The only way to truly master them is through deliberate practice. This page collects 21 conditional statement assignments, arranged from foundational if-else checks to more involved switch-case and nested-condition programs. Every assignment links to a full tutorial with the program code, sample output, and a line-by-line explanation.
🔹 If & If-Else Basics
Start here — validate conditions, branch on outcomes, and choose between two or more paths.
- 1. Write a program in C language to validate or check whether a given number is positive or negative using the if statement.
- 3. Write a program in C that calculates student grades based on marks given using if-else statements.
- 13. Develop a program in C language to check if a number is positive, negative, or zero using if-else statements.
- 16. Write a program in C to find the absolute value of a number using if-else statements.
- 20. C language program to check if a given character is a special character or digit using if-else statement.
🔹 Nested If & Maximum of Three Numbers
Combine conditions inside conditions to handle multi-level decision logic.
- 2. Write a program in C to find the maximum number among given three numbers using nested if-else statements only.
- 14. Write a program in C to find the maximum of three numbers using nested if-else statements.
🔹 Switch Case
Dispatch on discrete values — characters, digits, menu options, and categories.
- 6. Write a program in C to check whether a character is a vowel or a consonant using the switch-case statement.
- 7. Write a C program to calculate the electricity bill based on units consumed using switch-case.
- 8. Create a C program to determine the day of the week based on the input number using switch-case.
- 9. Develop a program in C to calculate the area of a triangle or rectangle based on user input using switch-case.
- 11. Create a program in C to determine the BMI category based on user input using switch-case.
- 15. Create a program in C to convert temperature from Celsius to Fahrenheit or vice versa using switch-case.
- 17. Write a program in C to check if a character is uppercase or lowercase using switch-case.
- 19. Develop a program in C to perform basic arithmetic operations based on user input using switch-case.
🔹 Ternary Operator
Replace simple if-else blocks with compact conditional expressions.
🔹 Math & Logic
Apply conditional logic to numerical and calendar-based problems.
- 5. Write a program in C to find the roots of a quadratic equation using if-else commands.
- 10. Write a program in C to check if a year is a leap year using if-else statements.
- 12. Implement a program in C language to check if a character is an alphabet, digit, or special character using if-else statements.
- 18. Create a program in C to determine the season based on the month using if-else statements.
- 21. Write a program in C to calculate the income tax based on the salary using if-else statements.
How to Get the Most Out of These Assignments
Reading a solution is not the same as writing one. For each assignment, follow this three-step workflow:
- Attempt first. Open a blank editor and try to solve the problem using only the assignment description. Even if you get stuck, the act of trying cements the concept.
- Compare carefully. Open the solution page and compare your approach to the reference. Look for differences in branching logic, edge cases, and operator precedence.
- Re-implement from scratch. Close the solution page and write the program again without looking. This is the step most learners skip — and it's the one that actually builds fluency.
💡 Tip: Compile with gcc -Wall -Wextra -std=c11 -g so the compiler flags suspicious conditions and unreachable branches. Watch out for the classic = vs == mistake inside conditions.