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

दिए गए C कोड का आउटपुट है:

The output of given C code is:

#include
int main ()
{
int x=1, y = 1, z;
z= x++ + y;
printf (“%d, %d”, x, y);
}
A)
B)
C)
D)

Explanation:

Let's analyze the given C code step by step:

Code:

#include 

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

Explanation:

  • int x = 1, y = 1, z;:
    The variables x and y are both initialized to 1. The variable z is declared but not initialized yet.

  • z = x++ + y;:
    The x++ is a post-increment operation. This means:

    • First, x is used in the expression with its current value (which is 1).
    • After the expression is evaluated, x is incremented by 1.
    • The value of y is 1 (since y was initialized to 1).
    • So, z = 1 (value of x++) + 1 (value of y) = 2.
    • After the operation, x becomes 2 (due to the post-increment), and y remains 1.
  • printf("%d, %d", x, y);:
    The printf statement will print the current values of x and y, which are 2 and 1, respectively.

Output:

The output will be: "2, 1"

Thus, the correct answer is:

(B) x=2, y=1.

Latest Updates