🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित कोड का परिणाम क्या है:

What is the output of the following code:

#include<stdio.h>
int main(){
int x=1, y=1,z;
z=x++ +y
printf("%d, %d",x,y);


A)
B)
C)
D)

Explanation:

The given C code contains the following:

#include
int main(){
    int x=1, y=1, z;
    z = x++ + y;
    printf("%d, %d", x, y);
}

Explanation:

  1. x = 1, y = 1: Initially, both x and y are set to 1.

  2. z = x++ + y:

    • x++ is the post-increment operator. It uses the current value of x (which is 1), and then increments x by 1.
    • So, z = 1 + 1 results in z = 2, and after this, x becomes 2 due to the post-increment.
  3. printf("%d, %d", x, y):

    • After the post-increment, x is 2 and y remains 1.

Thus, the output is:

Correct Answer:

(A) 2,1

Latest Updates