Which of the following statements is NOT true about if-else statement in C?

This question was previously asked in
RRB JE ECE 22 Apr 2025 Shift 1 CBT 2 Official Paper
View all RRB JE Papers >
  1. An if-else statement cannot be nested inside another if-else statement.
  2. If a condition is true, it is replaced by 1, if it false, it is replaced by 0.
  3. An if need not always be associated with an else. However, an else must always be associated with an if.
  4. The default scope of if and else statement is only the next statement. So, to execute multiple statements they must be written
    in a pair of braces.

Answer (Detailed Solution Below)

Option 1 : An if-else statement cannot be nested inside another if-else statement.
Free
General Science for All Railway Exams Mock Test
2.1 Lakh Users
20 Questions 20 Marks 15 Mins

Detailed Solution

Download Solution PDF

Explanation:

The given statement, "An if-else statement cannot be nested inside another if-else statement," is NOT true about the if-else statement in C. This is because in the C programming language, if-else statements can indeed be nested within each other. Nesting if-else statements means placing one or more if-else statements inside the code block of another if-else statement. This allows for the creation of more complex conditional logic structures to handle multiple conditions effectively.

Correct Option: Option 1

In C programming, nested if-else statements are used to evaluate multiple conditions in a hierarchical manner. Here's a detailed explanation:

Nested if-else Statement:

A nested if-else statement is an if-else statement that is contained within another if-else statement. This structure allows programmers to check for multiple conditions and execute different blocks of code based on the results of these conditions.

Example:


#include 

int main() {
    int x = 10;
    int y = 20;

    if (x == 10) {
        if (y == 20) {
            printf("x is 10 and y is 20\n");
        } else {
            printf("x is 10 but y is not 20\n");
        }
    } else {
        if (y == 20) {
            printf("x is not 10 but y is 20\n");
        } else {
            printf("x is not 10 and y is not 20\n");
        }
    }

    return 0;
}

In the above example, the nested if-else statements allow the program to check the values of both x and y and print appropriate messages based on their values.
Latest RRB JE Updates

Last updated on Jun 7, 2025

-> RRB JE CBT 2 answer key 2025 for June 4 exam has been released at the official website.

-> Check Your Marks via RRB JE CBT 2 Rank Calculator 2025

-> RRB JE CBT 2 admit card 2025 has been released. 

-> RRB JE CBT 2 city intimation slip 2025 for June 4 exam has been released at the official website.

-> RRB JE CBT 2 Cancelled Shift Exam 2025 will be conducted on June 4, 2025 in offline mode. 

-> RRB JE CBT 2 Exam Analysis 2025 is Out, Candidates analysis their exam according to Shift 1 and 2 Questions and Answers.

-> The RRB JE Notification 2024 was released for 7951 vacancies for various posts of Junior Engineer, Depot Material Superintendent, Chemical & Metallurgical Assistant, Chemical Supervisor (Research) and Metallurgical Supervisor (Research). 

-> The selection process includes CBT 1, CBT 2, and Document Verification & Medical Test.

-> The candidates who will be selected will get an approximate salary range between Rs. 13,500 to Rs. 38,425.

-> Attempt RRB JE Free Current Affairs Mock Test here

-> Enhance your preparation with the RRB JE Previous Year Papers

Get Free Access Now
Hot Links: teen patti wala game teen patti master game teen patti real cash withdrawal