Conditional Statements Assignments in C — 21 Programs with Solutions
  • Twitter
  • Facebook
  • Snapchat
  • Instagram

Conditional Statements Assignments in C Language with Explanation and Solutions

📑 Jump to a category:
  • If & If-Else Basics (1, 3, 13, 16, 20)
  • Nested If & Maximum (2, 14)
  • Switch Case (6–9, 11, 15, 17, 19)
  • Ternary Operator (4)
  • Math & Logic (5, 10, 12, 18, 21)
  • Previous / Next Topic
📚 What you'll practice across these 21 assignments:
  • 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.

Conditional statements assignments in C language — if, if-else, nested if, switch-case, and ternary operator, with step-by-step explanation and solutions.

🔹 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.

  • 4. Using the ternary operator ?: write a program in C to check whether a given year is a leap year.

🔹 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:

  1. 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.
  2. Compare carefully. Open the solution page and compare your approach to the reference. Look for differences in branching logic, edge cases, and operator precedence.
  3. 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.

📖 Related Tutorials

  • Decision Making Within A Program
  • Conditions in C
  • If Statement
  • If-Else Statement
  • If-Else Ladder
  • Nested If-Else
  • Switch Case
  • Conditional Statements Multiple-Choice Questions
  • Conditional Statements FAQ

Previous Topic: -->> Operators Assignments in C   ||   Next topic: -->> Loops Assignments in C


C Language

  • Home
  • Why C Language
  • History of C Language
  • Applications of C Language
  • Introduction To C
    • What is Program?
    • Structure of C Program
    • Working Of C Program
    • CHARACTER SET
    • VARIABLES AND IDENTIFIERS
    • BUILT-IN DATA TYPES
    • OPERATORS AND EXPRESSIONS
    • CONSTANTS AND LITERALS
    • SIMPLE ASSIGNMENT STATEMENT
    • BASIC INPUT/OUTPUT STATEMENT
    • SIMPLE 'C' PROGRAMS
    • Assignments
  • Operators in C Programming
    • Arithmetic Operators
    • Assignment Operators
    • Increment and Decrement Operators
    • Relational Operators
    • Logical Operators
    • Bitwise Operators
    • Other Operators
    • Assignments
  • CONDITIONAL STATEMENTS
    • DECISION MAKING WITHIN A PROGRAM
    • CONDITIONS
    • IF STATEMENT
    • IF-ELSE STATEMENT
    • IF-ELSE LADDER
    • NESTED IF-ELSE
    • SWITCH CASE
    • Assignments
  • LOOPS STATEMENTS
    • Introduction to Loops
    • GO TO Statement
    • Do while Loop
    • While Loop
    • Nested While Loop
    • Difference Between While and Do while
    • Difference Between Goto and loop
    • while loop assignments
    • C FOR Loop
    • C For loop examples
    • Nested for loop
    • Nested for loop examples
    • Infinite while Loops
    • Infinite for Loops
    • Continue in Loops
    • break in Loops
    • difference while do..while & for
    • Assignments
  • Arrays
    • One Dimensional Array
    • Declaring 1D Arrays
    • Initilization of 1D arrays
    • Accessing element of one 1D Array
    • Read and Display 1D Arrays
    • Two Dimensional Arrays
    • Declare 2D Arrays
    • Read and Display 2D Arrays
    • Assignments/Examples
  • Functions
    • Introduction
    • Need For User-Defined Function
    • Multiple Function Program
    • Modular Programming
    • Elements Of User Defined Function
    • Function Definition
    • Function Declaration
    • Types of functions
    • Nesting of Function
    • Recursion
    • Passing Array To Functions
    • Scope,Visibility and Lifetime of Variables
    • Assignments
  • Structure
    • Introduction
    • Array vs Structure
    • Defining Structure
    • Declaring Structure Variables
    • Type Defined Structure
    • Accessing Structure Members
    • Structure Initilization
    • Copying & Comparing Structure Variables
    • Array of Structure
    • Arrays Within Structure
    • Structures Within Structures
    • Structures and Functions
    • Structure Examples/Assignments
  • Union
    • Define Union
    • Create and use Union
    • Difference Between Structure and Union
    • Union Examples
    • Union FAQ
  • Pointers
    • What Are Pointers In C?
    • How Do We Use Pointers In C?
    • Declaration Of A Pointer
    • The Initialization Of A Pointer
    • Syntax Of Pointer Initialization
    • Use Of Pointers In C
    • The Pointer To An Array
    • The Pointer To A Function
    • The Pointer To A Structure
    • Types Of Pointers
    • The Null Pointer
    • The Void Pointer
    • The Wild Pointer
    • The Near Pointer
    • The Huge Pointer
    • The far Pointer
    • dangling pointer
    • Accessing Pointers- Indirectly And Directly
    • Pros Of Using Pointers In C
    • Cons Of Pointers In C
    • Applications Of Pointers In C
    • The & Address Of Operator In C
    • How To Read The Complex Pointers In C?
    • Practice Problems On Pointers
  • File Processiong
    • File Handling In C
    • Types Of Files In C
    • Operations Done In File Handling
    • File Examples
    • Binary Files
    • count words,lines in a file
    • Copy files
    • Update File
    • count vowels in a file
  • Preprocessor
    • Macro substitution division
    • File Inclusion
    • Conditional Compilation
    • Other directives
    • Examples
  • Dynamic Memory Allocation
    • malloc
    • calloc
    • free
    • realloc
    • Examples
  • Storage Classes
  • Graphics
  • Frequently Asked Interview Questions (FAQ)
    • Introduction To C FAQ
    • Operators FAQ
    • Conditional Statements FAQ
    • Loops FAQ
    • Arrays FAQ
    • Function FAQ
    • Structure FAQ
    • Pointers FAQ
    • Files FAQ
    • Storage classes FAQ
    • Dynamic Memory FAQ
  • Programs/Assignments
    • Introduction To C
    • Operators
    • Conditional Statements
    • Loops
    • Arrays
    • Function
    • Structure
    • Pointers
    • Files
    • Storage classes
    • Dynamic Memory
  • Case Studies
  • Multiple Choice Questions
    • Introduction To C MCQ
    • Operators MCQ
    • Conditional Statements MCQ
    • Loops MCQ
    • Arrays MCQ
    • Function MCQ
    • Structure MCQ
    • Pointers MCQ
    • Files MCQ
    • Storage classes MCQ
    • Dynamic Memory MCQ
    • More MCQ

Get in touch

  • tech2dsm@gmail.com

© Sankalan Data Tech. All rights reserved.