Question

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

Option 4 : 8 5

Advertisement

Detailed Solution

सही उत्तर 8 5 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

On a 64-bit system, what is the output of: char *s = "hello"; printf("%zu %zu", sizeof(s), strlen(s)); / 64-बिट सिस्टम पर इसका आउटपुट क्या है: char *s = "hello"; printf("%zu %zu", sizeof(s), strlen(s));

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

Correct Answer: 8 5

sizeof(s) is the size of the pointer itself (8 bytes on 64-bit), not the string; strlen counts characters excluding the null terminator, giving 5. Option (a) confuses sizeof(s) with sizeof("hello") which is 6. / sizeof(s) पॉइंटर का आकार है (64-बिट पर 8 बाइट), स्ट्रिंग का नहीं; strlen नल टर्मिनेटर को छोड़कर अक्षर गिनता है, अतः 5। विकल्प (a) sizeof(s) को sizeof("hello") (=6) से भ्रमित करता है।

Downloaded from PrepSnap (prepsnap.in)