MCQ on Conditional Statements in C — 22 Questions with Answers
  • Twitter
  • Facebook
  • Snapchat
  • Instagram

MCQ, Multiple Choice Questions on Conditional Statements in C

📑 On this page:
  • Basics of Conditional Statements
  • if and if-else
  • if-else Ladder
  • Nested if-else
  • Switch Case & break
  • Program Output Questions
  • Frequently Asked Questions
Multiple Choice questions on conditional statements in C including if, if-else, if-else ladder, nested if-else and switch case
MCQ on conditional statements in C — practice set with answers and simple explanations.
📚 In this quiz, you will revise:
  • How if, if-else, and if-else ladder work in C
  • Syntax rules for each conditional statement
  • How nested if-else allows multi-level decisions
  • Switch case and the role of the break statement
  • What happens when no case matches (default case)
  • How to read short C programs and predict their output

This page has 22 multiple choice questions on conditional statements in C. You'll find questions on if, if-else, if-else ladder, nested if-else, switch case, and the break keyword, plus a set of small code-output questions that test your reading skills. Each question comes with the correct answer and a short explanation in plain English, so you understand why an option is right and not just what it is. These MCQs are useful for beginners preparing for college exams, interviews, or any C programming test.

Basics of Conditional Statements

Q1. What is the purpose of conditional statements in C programming?

  • A) To perform mathematical calculations
  • B) To declare variables
  • C) To make decisions based on certain conditions
  • D) To execute code repeatedly

Answer: C) To make decisions based on certain conditions

Conditional statements let your program choose different paths depending on whether a condition is true or false. For example, you can print "Pass" if marks are 40 or more, and "Fail" otherwise. Loops like for and while handle repeated execution, which is a different job.

Q2. Which keyword is used to define a conditional statement in C?

  • A) switch
  • B) if
  • C) while
  • D) for

Answer: B) if

The if statement is the fundamental building block of decision making in C. It evaluates a condition: if the result is non-zero (true), the block runs; if zero (false), the block is skipped. while and for are loops, and switch is a multi-way selector — but if is the primary conditional keyword.

if and if-else Statements

Q3. Which one is the syntax of an if statement along with its body in C?

  • A) if (condition)
  • B) if (condition) { }
  • C) if condition
  • D) if { }

Answer: B) if (condition) { }

The condition must be inside parentheses, and the body of the if statement is enclosed in curly braces. Option A is missing the body, C is missing the parentheses, and D is missing the condition entirely. The braces keep your code readable and prevent unexpected behaviour when there are multiple statements.

Q4. Which is the syntax of an if-else statement in C?

  • A) if { } else { }
  • B) if condition else
  • C) if (condition) { }
  • D) if (condition) { } else { }

Answer: D) if (condition) { } else { }

An if-else statement has two branches: the if branch runs when the condition is true, and the else branch runs when the condition is false. The condition must be in parentheses, and each branch's body is wrapped in curly braces. This lets your program handle both the "yes" and "no" cases cleanly.

if-else Ladder

Q5. Which statement is used to check multiple conditions in C?

  • A) if-else
  • B) if(condition)
  • C) switch case
  • D) if-else ladder

Answer: D) if-else ladder

An if-else ladder is used when you have several conditions to test one after another. Each else if is checked in order. As soon as one condition matches, its body runs and the rest are skipped. It's a clean way to handle things like grade calculation (A/B/C/D/Fail) based on marks.

Q6. Which one is the correct syntax for an if-else ladder in C?

  • A) if (condition) { } else if (condition) { }
  • B) if (condition) { } else { } elseif (condition) { }
  • C) if (condition) { } elseif (condition) { } else { }
  • D) if (condition) { } else if (condition) { } else { }

Answer: D) if (condition) { } else if (condition) { } else { }

C uses "else if" with a space, not "elseif" as in PHP or "elif" as in Python. The final else is optional and acts as a catch-all when none of the earlier conditions match. This structure can be chained as deep as you need.

Nested if-else

Q7. Identify the true statement about nested if-else statements.

  • A) They cannot have else branches
  • B) They can only have a single level of nesting
  • C) They cannot contain conditions
  • D) They can have multiple levels of nesting

Answer: D) They can have multiple levels of nesting

A nested if-else is an if-else placed inside another if or else block. C allows this to any depth, which is useful when decisions depend on more than one condition. For example, first check if a student passed, and inside that, check whether their grade is A, B, or C. Deep nesting can hurt readability, so it's best to keep it to 2–3 levels.

Switch Case & break

Q8. Which statement handles multiple conditions on a single variable in C?

  • A) if-else ladder
  • B) switch case
  • C) if
  • D) if-else

Answer: B) switch case

Switch case is designed for comparing one variable against a set of constant values. It's cleaner than an if-else ladder when you have many fixed options, like menu choices (1 = Add, 2 = Delete, 3 = Exit). Note that switch works only with integer or char values in C, not float or string.

Q9. Identify the correct syntax for a switch case statement in C.

  • A) case expression:
  • B) case { }
  • C) switch (expression) { }
  • D) switch { }

Answer: C) switch (expression) { }

The switch keyword is followed by an expression in parentheses, and the body (containing case labels) is enclosed in curly braces. Inside the braces, you write case values and an optional default. Unlike if, the switch expression must be an integer type (int, char, enum).

Q10. Which one is true about the break statement in a switch case?

  • A) To skip the current case
  • B) To end the program
  • C) To exit the switch case statement
  • D) To exit the loop

Answer: C) To exit the switch case statement

Inside a switch, break tells the program to leave the switch block immediately. Without it, execution falls through to the next case automatically — this is called fall-through. Inside loops, break also works, but in the switch-case context its purpose is to stop the switch from continuing to the next case.

Q11. What if no corresponding or matching case is available in a switch case statement?

  • A) The default case is executed
  • B) The program continues to the next case
  • C) The program terminates
  • D) An error occurs

Answer: A) The default case is executed

The default case is the fallback. If no case label matches the switch expression, the default block runs. If you don't write a default and nothing matches, the switch simply does nothing and control passes to the next statement after the switch block. This is safe, but adding a default is good practice for clarity.

Program Output Questions

Q12. Read the following program and find the output.

int p = 15;
if (p > 3)
{
    printf("p is greater than 3\n");
}
else
{
    printf("p is not greater than 3\n");
}
  • A) p is greater than 3
  • B) p is not greater than 3
  • C) 15
  • D) Compilation error

Answer: A) p is greater than 3

The value of p is 15, which is greater than 3. So the if condition (p > 3) is true, and the if block runs. It prints "p is greater than 3". The else block is skipped because the condition was already satisfied.

Q13. What is the output of the following code?

int p = 15, q = 13;
if (p > q)
{
    printf("p is greater than q\n");
}
else
{
    printf("p is not greater than q\n");
}
  • A) p is greater than q
  • B) p is not greater than q
  • C) 15
  • D) Compilation error

Answer: A) p is greater than q

Here p is 15 and q is 13. Since 15 is greater than 13, the if condition (p > q) is true, and the if block runs. It prints "p is greater than q". The else block is not executed.

Q14. What is the output of the following code?

int p = 15, q = 18;
if (p > q)
{
    printf("%d is greater than %d\n", p, q);
}
else
{
    printf("%d is not greater than %d\n", p, q);
}
  • A) p is greater than q
  • B) 15 is not greater than 18
  • C) 15
  • D) error

Answer: B) 15 is not greater than 18

Here p is 15 and q is 18. Since 15 is not greater than 18, the if condition is false, so the else block runs. The printf inside the else substitutes the actual values of p and q, printing "15 is not greater than 18".

Q15. What is the output of the following code?

int x = 15, y = 18;
if (x < y)
{
    printf("%d is less than %d\n", x, y);
}
  • A) 15 is less than 18
  • B) 15 is greater than 18
  • C) Compilation error
  • D) No output

Answer: A) 15 is less than 18

Here x is 15 and y is 18, and 15 is less than 18. So the if condition is true and its body runs. Since there is no else, the code prints "15 is less than 18" and then ends.

Q16. What is the correct output of the following program code?

int x = 50, y = 80;
if (x > y)
{
    printf("value of x is greater than value of y\n");
}
else if (x < y)
{
    printf("value of x is less than the value of y\n");
}
  • A) value of x is greater than the value of y
  • B) value of x is less than the value of y
  • C) runtime error
  • D) No output

Answer: B) value of x is less than the value of y

Here x is 50 and y is 80. The first condition (x > y) is false, so it moves to the else if. Since x < y is true (50 < 80), the else if branch runs and prints "value of x is less than the value of y".

Q17. Find the output of the following code.

int p = 56, q = 56;
if (p > q)
{
    printf("p is greater than q\n");
}
else if (p < q)
{
    printf("p is less than q\n");
}
else
{
    printf("p is equal to q\n");
}
  • A) p is greater than q
  • B) p is less than q
  • C) p is equal to q
  • D) No output

Answer: C) p is equal to q

Here p and q are both 56. The first check (p > q) is false because 56 is not greater than 56. The second check (p < q) is also false. So the final else runs, printing "p is equal to q". This is why the final else in a ladder is important — it catches the case where nothing above matched.

Q18. What is the output of the following code?

int p = 15;
switch (p)
{
    case 1:
        printf("One is One !\n");
        break;
    case 5:
        printf("Five is Five !\n");
        break;
    case 2:
        printf("Two !\n");
        break;
    default:
        printf("I am Default\n");
        break;
}
  • A) One is One!
  • B) Two !
  • C) I am Default
  • D) Error

Answer: C) I am Default

The value of p is 15, which doesn't match any of the case labels (1, 5, or 2). Since no case matches, the default block runs, printing "I am Default". This is exactly why default is useful — it handles unexpected values.

Q19. Which option is the correct output of the following code?

int x = 1;
switch (x)
{
    case 1:
        printf("I am Number One\n");
    case 2:
        printf("I am Number Two\n");
        break;
    default:
        printf("I am Default\n");
        break;
}
  • A) I am Number One
  • B) I am Number One followed by I am Number Two
  • C) I am Number Two
  • D) I am Number One followed by I am Default

Answer: B) I am Number One followed by I am Number Two

Because there is no break after case 1, the execution "falls through" to case 2 automatically. So both "I am Number One" and "I am Number Two" print. The break after case 2 stops the fall-through at that point. This is a classic fall-through trap that appears in almost every C exam.

Q21. What is the output of the following program?

int p = 11;
switch (p)
{
    case 11:
        printf("Eleven\n");
    case 22:
        printf("Twenty Two\n");
    case 33:
        printf("Thirty Three\n");
        break;
    default:
        printf("Default\n");
        break;
}
  • A) Eleven
  • B) Twenty Two
  • C) Eleven, then Twenty Two, then Thirty Three
  • D) Default

Answer: C) Eleven, then Twenty Two, then Thirty Three

The switch enters case 11 because p = 11. But there is no break after case 11 or case 22, so execution keeps falling through. All three printf statements run, in order, until the break after case 33 stops the fall-through. So the output is "Eleven", then "Twenty Two", then "Thirty Three".

Q22. What is the output of the following code?

int x = 33;
switch (x)
{
    case 11:
        printf("Eleven\n");
        break;
    case 12:
        printf("Twelve\n");
        break;
}
  • A) Eleven
  • B) Twelve
  • C) No output
  • D) Compilation error

Answer: C) No output

Here x is 33, and the only cases are 11 and 12. Since neither matches and there is no default case, the switch does nothing. The program doesn't crash and doesn't print anything — it just moves on. Adding a default case would have given some output instead of silence.

Frequently Asked Questions

What is the difference between if-else and switch case in C?

if-else works with any kind of condition — ranges, comparisons, complex expressions. switch case works only on integer or char values matched against constant case labels. Use if-else for complex logic and switch case for checking one variable against many fixed values, like a menu system.

Why is break important inside a switch case?

Without break, execution falls through to the next case automatically. This is called fall-through. It can be intentional in rare cases (like grouping cases that should share code), but usually it's a bug. Add break after each case to make sure only one branch runs.

Can a switch case work with float or string values in C?

No. In C, switch works only with integer types (int, char, enum). It does not accept float, double, or strings as the switch expression or case label. If you need to compare strings, use if-else with strcmp() from string.h.

What happens if the else block is missing in an if statement?

The else block is optional. If it's omitted and the condition is false, the if block is simply skipped and execution continues after the if statement. No error is thrown. You only need else when you have a separate action for the false case.

How many else if branches can an if-else ladder have?

There is no fixed limit. You can chain as many else if branches as your logic requires. However, if you have many branches testing the same variable against fixed values, switch case is usually cleaner and faster.

💡 Tip: Try to answer all 22 questions before checking the answers. Pay extra attention to the switch case questions — fall-through (missing break) is the number one mistake tested in C exams.

📖 Related MCQ Pages

  • Introduction to C MCQ
  • Operators MCQ
  • Loops MCQ
  • Arrays MCQ
  • Functions MCQ
  • Structures MCQ
  • Pointers MCQ
  • Files MCQ
  • Storage Classes MCQ
  • Dynamic Memory MCQ

Previous Topic: -->> Operators MCQ   ||   Next topic: -->> Loops MCQ


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 Processing
    • 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.