Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 4 : 4 / 4
Advertisement
Detailed Solution
सही उत्तर 4 / 4 है।
Key Points
Helpful?
Question:
What is the output of the following C code? `int i = 0; while (i++ < 3) ; printf("%d", i);` / निम्नलिखित C कोड का आउटपुट क्या होगा? `int i = 0; while (i++ < 3) ; printf("%d", i);`
1.
3 / 3
2.
Infinite loop / अनंत लूप
3.
2 / 2
4.
4 / 4
Correct Answer: 4 / 4
The post-increment still executes on the failing comparison: comparisons run with i = 0, 1, 2 (true) and i = 3 (false), and each one increments i, leaving i = 4. The trap is counting only the successful iterations. / असफल तुलना पर भी post-increment चलता है: तुलनाएँ i = 0, 1, 2 (सत्य) और i = 3 (असत्य) पर होती हैं, और हर बार i बढ़ता है, अतः अंत में i = 4। जाल केवल सफल पुनरावृत्तियाँ गिनना है।
Downloaded from PrepSnap (prepsnap.in)