प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Given int find(int *a, int n, int k) { int i; for (i = 0; i < n; i++) if (a[i] == k) return i; return -1; }, what is printed by int a[] = {4, 8, 15, 16, 23, 42}; printf("%d", find(a, 6, 16)); ?
सही उत्तर: क) 3
Linear search returns the index of the first match; 16 is at index 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int i, s = 0; for (i = 1; i <= 5; i++) s += i % 2 ? i : -i; printf("%d", s);
सही उत्तर: घ) 3
The conditional binds tighter than +=, so s = 1 - 2 + 3 - 4 + 5 = 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given int odd(int n); int even(int n) { return n == 0 ? 1 : odd(n - 1); } int odd(int n) { return n == 0 ? 0 : even(n - 1); }, what is printed by printf("%d", even(7)); ?
सही उत्तर: ग) 0
The mutually recursive functions alternate until n reaches 0; starting from even(7) they end in odd(0), which returns 0 because 7 is not even.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given int cnt(char *s, char c) { return *s ? (*s == c) + cnt(s + 1, c) : 0; }, what is printed by printf("%d", cnt("banana", 'a')); ?
सही उत्तर: ख) 3
Each recursive call adds 1 when the current character equals 'a'; "banana" has three a's.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: printf("%x", 255 & ~15);
सही उत्तर: क) f0
~15 clears the lowest four bits, so 255 & ~15 = 240, which %x prints in hexadecimal as f0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: char s[] = "aabbbc"; int i, mx = 1, cur = 1; for (i = 1; s[i]; i++) { if (s[i] == s[i - 1]) cur++; else cur = 1; if (cur > mx) mx = cur; } printf("%d", mx);
सही उत्तर: घ) 3
The code finds the longest run of equal adjacent characters; 'bbb' has length 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, i, s = 0; for (i = 0; i < 3; i++) s += m[i][2 - i]; printf("%d", s);
सही उत्तर: ग) 15
m[i][2 - i] walks the anti-diagonal: 3 + 5 + 7 = 15.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int n = 3; char c = 'A' + n * 2; printf("%c", c);
सही उत्तर: ख) G
'A' + 6 is the seventh letter of the alphabet, 'G'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int a[] = {9, 8, 7, 6, 5}, i, s = 0; for (i = 0; i < 5; i += 2) s += a[i]; printf("%d", s);
सही उत्तर: क) 21
The loop adds the elements at indices 0, 2 and 4: 9 + 7 + 5 = 21.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int n = 25, z = 0; while (n) { n /= 5; z += n; } printf("%d", z);
सही उत्तर: घ) 6
This counts trailing zeros of 25!: 25/5 = 5 and 5/5 = 1, so z = 5 + 1 = 6.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।