प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
What is printed by the C code: printf("%c", 'a' + 25); ?
सही उत्तर: घ) z
The letters are consecutive in ASCII, so 25 places after 'a' is 'z'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char s[] = "NePaL"; int i, c = 0; for (i = 0; s[i]; i++) if (isupper(s[i])) c++; printf("%d", c); ?
सही उत्तर: घ) 3
The loop runs until the null character and counts the upper-case letters N, P and L using isupper().
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char str[] = "abcde"; char *p = str + 3; printf("%s", p); ?
सही उत्तर: क) de
p points to str[3], which is d, and %s prints from there up to the null terminator.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: float f = 0.1f; if (f == 0.1) printf("equal"); else printf("not equal"); ?
सही उत्तर: ख) not equal
0.1 cannot be stored exactly in binary; the float approximation differs from the double constant 0.1, so the comparison is false.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i = 0, j = 0; if (i++ || j++) ; printf("%d %d", i, j); ?
सही उत्तर: ग) 1 1
i++ yields 0 (false), so || must also evaluate j++; afterwards both i and j are 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C, given int f(int n) { if (n == 1) return 0; return 1 + f(n % 2 ? 3 * n + 1 : n / 2); } what is printed by printf("%d", f(6)); ?
सही उत्तर: ग) 8
The sequence is 6, 3, 10, 5, 16, 8, 4, 2, 1, which takes 8 steps to reach 1, and f counts the steps.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C, given void f(void) { static int c = 0; c++; printf("%d", c); } what is printed by f(); f(); f(); ?
सही उत्तर: घ) 123
A static local variable is initialised only once and keeps its value between calls, so it prints 1, 2 and 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int c = 0, n = 29; while (n) { c += n & 1; n >>= 1; } printf("%d", c); ?
सही उत्तर: क) 4
29 is 11101 in binary; the loop adds each lowest bit before shifting, counting the four 1-bits.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int n = 12345, r = 0; while (n) { r = r * 10 + n % 10; n /= 10; } printf("%d", r); ?
सही उत्तर: ख) 54321
Each pass takes the last digit (n % 10), appends it to r and drops it from n, so the number is reversed.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a = 3, b = 4; printf("%d", a++ * --b); ?
सही उत्तर: ख) 9
a++ yields the old value 3 and --b yields the new value 3, so the product is 3 * 3 = 9.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।