Question

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

Option 2 : a negative value / एक ऋणात्मक मान

Advertisement

Detailed Solution

सही उत्तर a negative value / एक ऋणात्मक मान है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What is the output of: printf("%d", strcmp("abc", "abcd")); / इसका आउटपुट क्या है: printf("%d", strcmp("abc", "abcd"));

1.
1
2.
a negative value / एक ऋणात्मक मान
3.
0
4.
a positive value / एक धनात्मक मान

Correct Answer: a negative value / एक ऋणात्मक मान

strcmp compares character by character; the first three characters match, then '\0' (0) is compared with 'd' (100), so "abc" is smaller and strcmp returns a negative value. The trap is comparing lengths (3 vs 4) and concluding positive. / strcmp अक्षर-दर-अक्षर तुलना करता है; पहले तीन अक्षर मिलते हैं, फिर '\0' (0) की 'd' (100) से तुलना होती है, अतः "abc" छोटा है और strcmp ऋणात्मक मान लौटाता है। जाल लंबाइयों (3 बनाम 4) की तुलना करके धनात्मक निष्कर्ष निकालना है।

Downloaded from PrepSnap (prepsnap.in)