Question

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

Option 4 : 7

Advertisement

Detailed Solution

सही उत्तर 7 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What does the following C sizeof program output? / sizeof वाले निम्नलिखित C प्रोग्राम का आउटपुट क्या है?

#include <stdio.h> int main() { char s[] = "TGT-CS"; printf("%d", (int)sizeof(s)); return 0;}

1.
6
2.
8
3.
5
4.
7

Correct Answer: 7

The string holds 6 characters plus the terminating null character, so sizeof gives 7. Option (a) forgets the null terminator. / स्ट्रिंग में 6 अक्षर और अंत का null अक्षर है, अतः sizeof 7 देता है। विकल्प (a) null terminator भूल जाता है।

Downloaded from PrepSnap (prepsnap.in)