Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 3 : Unspecified — depends on the compiler's order of argument evaluation / अनिर्दिष्ट — कंपाइलर के आर्गुमेंट मूल्यांकन क्रम पर निर्भर

Advertisement

Detailed Solution

सही उत्तर Unspecified — depends on the compiler's order of argument evaluation / अनिर्दिष्ट — कंपाइलर के आर्गुमेंट मूल्यांकन क्रम पर निर्भर है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What is the output of the following C code? `int x = 5; printf("%d %d", x++, ++x);` / निम्नलिखित C कोड का आउटपुट क्या होगा? `int x = 5; printf("%d %d", x++, ++x);`

1.
5 7 / 5 7
2.
5 6 / 5 6
3.
Unspecified — depends on the compiler's order of argument evaluation / अनिर्दिष्ट — कंपाइलर के आर्गुमेंट मूल्यांकन क्रम पर निर्भर
4.
6 7 / 6 7

Correct Answer: Unspecified — depends on the compiler's order of argument evaluation / अनिर्दिष्ट — कंपाइलर के आर्गुमेंट मूल्यांकन क्रम पर निर्भर

The C standard does not fix the order in which function arguments are evaluated, and `x++` and `++x` both modify `x` without a sequence point between them, so the result is unspecified and varies across compilers. Assuming left-to-right evaluation is the trap. / C मानक फंक्शन आर्गुमेंटों के मूल्यांकन का क्रम तय नहीं करता, और `x++` तथा `++x` दोनों बिना sequence point के `x` को बदलते हैं, अतः परिणाम अनिर्दिष्ट है और कंपाइलर के अनुसार बदलता है। बाएँ-से-दाएँ मूल्यांकन मान लेना ही जाल है।

Downloaded from PrepSnap (prepsnap.in)