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

Consider the following code snippet in C programming language. 

int n = 5; 

int m = n++; 

What is the value of m after execution?

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

5

To determine the value of m after the execution of the given C code snippet, let's analyze the code step-by-step:

  1. The code begins by initializing an integer variable n with the value 5:
    int n = 5;
  2. Next, another integer variable m is declared and assigned the value of n++:
    int m = n++;
    • Here, n++ is the postfix increment operator. In postfix incrementation, the current value of n is used in the expression, and then n is incremented by 1.
    • The current value of n before the increment is 5.
    • This value 5 is assigned to m.
    • After the assignment, n is incremented, making n = 6.

Thus, after executing the code, the value of m is 5. This is because the postfix operator uses the value before incrementation.

Conclusion: The value of m after execution is 5. Therefore, the correct answer is 5.

Was this answer helpful?

Similar Questions

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

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

  3. 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?

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

  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. Which one is the reserved word in C language ?

  2. Which of the following is the feature(s) of High level programming languages?

    I. Portability

    II. Easy debugging

  3. Which of the following is a type of subprogram?

    I. Function

    II. Subroutine

  4. In object-oriented programming, which keyword ensures that a member variable belongs to the class itself rather than to any specific object, thereby allowing all instances to share a single copy of that variable?

  5. The condition num! = 65 cannot be replaced by

Need Expert Advice?
Test Series
RRB JE img
Railways
RRB JE Prev. Yr. Paper (CBT 1 + CBT 2) Test Series
290 Tests 5 Tests Free
4860 Attempts
4.3(90)
English

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