प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
With #define ABS(x) x < 0 ? -x : x in C, what is printed by printf("%d", ABS(2 - 5)); ?
सही उत्तर: ग) -7
The macro expands to 2 - 5 < 0 ? -2 - 5 : 2 - 5; the condition is true, so -2 - 5 = -7. Missing parentheses cause the error.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given int f(int n) { static int s = 0; s += n; if (n > 0) f(n - 1); return s; }, what does f(4) return when called once?
सही उत्तर: ख) 10
The single static s accumulates 4 + 3 + 2 + 1 + 0 = 10 across all recursive calls, and the outer call returns it.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char *p = "Kathmandu"; int n = 0; while (*p) { if (strchr("aeiou", *p)) n++; p++; } printf("%d", n); ?
सही उत्तर: क) 3
strchr finds each lower-case vowel; Kathmandu contains a, a and u, so n = 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char s[10] = "ab"; strncat(s, "cdef", 2); printf("%s", s); ?
सही उत्तर: घ) abcd
strncat appends at most 2 characters of "cdef" ("cd") and a terminating '\0', giving "abcd".
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: struct pt { int x, y; } a[3] = {{1, 2}, {3, 4}, {5, 6}}; struct pt *p = a; p++; printf("%d", p->x + (p + 1)->y); ?
सही उत्तर: ग) 9
After p++, p points to a[1], so p->x = 3, and (p + 1)->y is a[2].y = 6; 3 + 6 = 9.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i, count = 0; for (i = 0; i < 20; i++) if (i % 3 == 0 || i % 5 == 0) count++; printf("%d", count); ?
सही उत्तर: ख) 9
Multiples of 3 below 20: 7 (including 0); multiples of 5: 4 (including 0); 0 and 15 are counted in both, so 7 + 4 - 2 = 9.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i, j; for (i = 0, j = 5; i < j; i += 2, j--); printf("%d %d", i, j); ?
सही उत्तर: क) 4 3
(i, j) goes (0,5), (2,4), (4,3); now 4 < 3 is false, so 4 3 is printed. Note the empty loop body.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i, j, c = 0; for (i = 1; i <= 4; i++) for (j = i; j <= 4; j++) c += j; printf("%d", c); ?
सही उत्तर: घ) 30
Sums are 1+2+3+4 = 10, 2+3+4 = 9, 3+4 = 7 and 4, giving 10 + 9 + 7 + 4 = 30.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i = 10; do printf("%d ", i); while (--i > 7); ?
सही उत्तर: ग) 10 9 8
10 is printed first; --i gives 9 (>7) and 8 (>7), both printed; then 7 > 7 is false.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char s[] = "Nepal"; printf("%d", (int)(sizeof(s) - strlen(s))); ?
सही उत्तर: ख) 1
sizeof(s) is 6 (it includes the terminating '\0') while strlen(s) is 5, so the difference is 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।