All Exams Test series for 1 year @ ₹349 only
Question

Which statement is TRUE about if statement in the C programming language?

This question was previously asked in
RRB JE 2025 CBT 2 Mechanical and Allied Engg Question Paper English (2-Jul-2026) (Shift-1)
The correct answer is

A non-zero value written in the condition means True

C does not have a dedicated boolean type in its original standard; instead it treats integer (and pointer) values as truth values in a condition. The rule is simple and fundamental: the value 0 is interpreted as False, and any non-zero value is interpreted as True. This applies to the controlling expression of if, while, for and the ternary operator alike.

Consequences of this rule are that if(5), if(-1) and if(0.1) all take the True branch because none of these values is zero, whereas if(0) takes the False branch (or the else, if present).

Evaluating the statements:

  • A non-zero value in the condition means True — this is the correct statement and a direct restatement of C's truth rule.
  • The claim that a value of 0 means True is the reverse of the actual convention; 0 means False.
  • The claim that every if must have a matching else is wrong: the else clause is entirely optional, and a lone if is perfectly valid.
  • The claim that if statements cannot be nested is also wrong; nesting one if inside another (or inside an else) is common and fully supported.

Hence only the statement that a non-zero condition value means True is correct.

Was this answer helpful?

Similar Questions

  1. Consider the following code snippet in C programming language. 

    int n = 5; 

    int m = n++; 

    What is the value of m after execution?

  2. You need to read a floating-point value from the user in the C programming language. Which of the following statements correctly performs this task?

  3. What are the statements that begin with # symbol called in C programming language?

  4. Which shape is used to represent a decision in a flowchart?

  5. What is the output of the give C language code snippet? 

    void f(int x)

    {

     x = x + 5;

     }

     int main()

    { 

    int a = 10;

     f(a); 

    printf("%d",a); 

    return 0; 

    }


Important Questions from Programming in C

  1. Consider the following C program:
    #include <stdio.h>
    int g(int n) {
    return (n+10);
    }
    int f(int n) {
    return g(n*2);
    }
    int main() {
    int sum, n;
    sum=0;
    for (n=1; n<3; n++)
    sum + = g(f(n));
    printf ("%d", sum);
    return 0;
    }
    The output of the given C program is ____________ (Answer in integer)

  2. Determine what's true for x, if we define int *x[10] ?
  3. In bitwise operator, each right shift operator divides by ________.
  4. In Switch-case, the ________ is not allowed to be case labels.
  5. In C++, ________ functions are not actually called, rather, their codes are expanded
Need Expert Advice?
Test Series
RRB JE img
Railways
RRB JE (CBT 1 + CBT 2) 2026 Mock Test Series
1515 Tests 19 Tests Free
1833 Attempts
4.3(163)
English, Hindi

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App