C decision-making examples
C Programs - Conditional
Practice C programs based on if-else, switch, break, continue, and ternary conditional logic.
Topic library
18
practice programs
Topic overview
C statements normally run sequentially, but conditional statements let a program choose what to execute based on a condition.
In C, common decision-making tools include if statements, if-else statements, if-else ladders, nested if-else, switch statements, and the conditional or ternary operator.
These examples help you practice writing clear conditions and choosing the correct branch for each problem.
Practice list
If-else programs in C
- 1C program to check if number is even or odd
- 2C Program to find maximum between two numbers
- 3C Program to find maximum between three numbers
- 4C Program to check if number is positive, negative or zero
- 5C program to check if a year is leap year or not
- 6C program to check if a character is alphabet or not
- 7C program to check if a given alphabet is vowel or consonant
- 8C program to check if a given character is an alphabet, digit, or special character
- 9C program to check if a character is uppercase or lowercase alphabet
- 10C program to input angles of a triangle and check whether triangle is valid or not
- 11C program to input all sides of a triangle and check if triangle is valid or not
- 12C program to check if the triangle is equilateral, isosceles or scalene triangle
- 13C program to find all roots of a quadratic equation
- 14C program to calculate profit or loss
Practice list