DSSSB TGT CS Mock 02 – Question 170

Question:

Consider the following C code snippet:

int x = 10;
int *p = &x;
*p = *p + 5;
printf("%d", x);

What is the output printed on the console?

निम्नलिखित C कोड स्निपेट पर विचार करें:

int x = 10;
int *p = &x;
*p = *p + 5;
printf("%d", x);

कंसोल पर क्या आउटपुट प्रदर्शित होगा?

Options:

  • 15
  • 10
  • 5
  • Garbage value
  • 15
  • 10
  • 5
  • कचरा मान (Garbage value)

Correct Answer: a)

Explanation:

`p` holds the memory address of `x`. Dereferencing `*p` directly modifies the value stored at `x`: `*p = 10 + 5 = 15`. Thus, printing `x` displays 15 (Option a).

पॉइंटर `p`, चर `x` के पते को संदर्भित करता है। `*p` के माध्यम से मान बदलने पर `x` का मान 10 से बढ़कर 15 हो जाता है (विकल्प a)।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top