Question

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

Option 4 : 10 5 / 10 5

Advertisement

Detailed Solution

सही उत्तर 10 5 / 10 5 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What is the output of the following C program involving a while loop that accumulates a sum? / योग संचय करने वाले while लूप वाले निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h> int main() { int i = 0, s = 0; while (i < 5) { s += i++; } printf("%d %d", s, i); return 0; }

1.
15 5 / 15 5
2.
10 4 / 10 4
3.
15 4 / 15 4
4.
10 5 / 10 5

Correct Answer: 10 5 / 10 5

s accumulates 0 + 1 + 2 + 3 + 4 = 10, and the loop terminates when i reaches 5. / s में 0 + 1 + 2 + 3 + 4 = 10 जुड़ता है और लूप तब समाप्त होता है जब i, 5 पर पहुँचता है।

Downloaded from PrepSnap (prepsnap.in)