प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Determine the output of this C fragment: char *s = "education"; int v = 0; while (*s) { switch (*s++) { case 'a': case 'e': case 'i': case 'o': case 'u': v++; } } printf("%d", v);
सही उत्तर: क) 5
The stacked case labels count vowels; 'education' contains e, u, a, i and o, so v is 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: char s[] = "Ram2024!"; int i, d = 0, a = 0; for (i = 0; s[i]; i++) { if (isdigit(s[i])) d++; else if (isalpha(s[i])) a++; } printf("%d %d", d, a);
सही उत्तर: घ) 4 3
The string has 4 digits (2, 0, 2, 4) and 3 letters (R, a, m); '!' is neither.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: printf("%d", (0xAB >> 4) & 0xF);
सही उत्तर: ग) 10
0xAB >> 4 gives 0xA, and masking with 0xF keeps it as 0xA, which is 10 in decimal.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int a[] = {4, 7, 4, 9, 7}, i, x = 0; for (i = 0; i < 5; i++) x ^= a[i]; printf("%d", x);
सही उत्तर: ख) 9
XOR of a number with itself is 0, so the pairs of 4 and 7 cancel and only 9 remains.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int n = 40, c = 0; while (!(n & 1)) { n >>= 1; c++; } printf("%d", c);
सही उत्तर: क) 3
40 is 101000 in binary; the loop counts trailing zero bits, which are 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int a = 1, b = 2, *p = &a, *q = &b, *t; t = p; p = q; q = t; printf("%d %d %d %d", a, b, *p, *q);
सही उत्तर: घ) 1 2 2 1
Only the pointers are swapped, not the variables, so a and b stay 1 and 2 while p now points to b and q to a.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int a[] = {1, 2, 3, 4, 5}, i, j, c = 0; for (i = 0; i < 5; i++) for (j = i + 1; j < 5; j++) if (a[i] + a[j] == 6) c++; printf("%d", c);
सही उत्तर: ग) 2
Only the pairs (1, 5) and (2, 4) have sum 6; (3, 3) is not counted because j always starts after i.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int a[] = {1, 2, 3, 4}, i; for (i = 1; i < 4; i++) a[i] += a[i - 1]; printf("%d", a[3]);
सही उत्तर: ख) 10
The loop turns the array into running totals 1, 3, 6, 10, so a[3] is 10.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given int A(int m, int n) { if (m == 0) return n + 1; if (n == 0) return A(m - 1, 1); return A(m - 1, A(m, n - 1)); }, what is printed by printf("%d", A(2, 1)); ?
सही उत्तर: क) 5
This is the Ackermann function: A(1, n) = n + 2 and A(2, n) = 2n + 3, so A(2, 1) = 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given int C(int n, int k) { return k == 0 || k == n ? 1 : C(n - 1, k - 1) + C(n - 1, k); }, what is printed by printf("%d", C(5, 2)); ?
सही उत्तर: घ) 10
The function computes binomial coefficients with Pascal's rule, so C(5, 2) = 5! / (2! 3!) = 10.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।