Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 2 : 3 7
Advertisement
Detailed Solution
सही उत्तर 3 7 है।
Key Points
Helpful?
Question:
What is the output of the following C program? char s[] = "TGT\0CS"; printf("%d %d", (int)strlen(s), (int)sizeof(s)); / निम्नलिखित C प्रोग्राम का आउटपुट क्या है?
1.
6 7
2.
3 7
3.
3 6
4.
7 7
Correct Answer: 3 7
strlen stops at the first null character, so it counts only "TGT" = 3. sizeof counts the whole array: T, G, T, \0, C, S plus the terminating \0 = 7 bytes. / strlen पहले null अक्षर पर रुक जाता है, इसलिए वह केवल "TGT" = 3 गिनता है। sizeof पूरे ऐरे को गिनता है: T, G, T, \0, C, S तथा अंतिम \0 = 7 बाइट।
Downloaded from PrepSnap (prepsnap.in)