प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
With #define CUBE(x) ((x) * (x) * (x)) in C, what is printed by printf("%d", CUBE(1 + 1)); ?
सही उत्तर: घ) 8
Because every use of x is parenthesised, CUBE(1 + 1) becomes ((1 + 1) * (1 + 1) * (1 + 1)) = 8.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char s1[10] = "Hi", s2[] = "Nepal"; strcpy(s1, s2 + 2); printf("%s %d", s1, (int)strlen(s1)); ?
सही उत्तर: ग) pal 3
strcpy replaces the old contents of s1 with the string starting at s2 + 2, which is "pal" (length 3).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Using the logical NOT operator in C, what value does printf("%d", !(3 > 2) + !0 * 5); output?
सही उत्तर: ख) 5
!(3 > 2) is 0 and !0 is 1, so the result is 0 + 1 * 5 = 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int flags = 0xF; flags &= ~(1 << 1); printf("%d", flags); ?
सही उत्तर: घ) 13
0xF is 1111; ~(1 << 1) clears bit 1, giving 1101 = 13.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
On an ASCII system, what is printed by the C code: char c = 'a'; c -= 32; printf("%d %c", c, c + 1); ?
सही उत्तर: ख) 65 B
'a' is 97; subtracting 32 gives 65 ('A'), so %d prints 65 and c + 1 printed with %c is 'B'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a[] = {4, 1, 3}, i, j, t; for (i = 0; i < 2; i++) for (j = 0; j < 2 - i; j++) if (a[j] < a[j + 1]) { t = a[j]; a[j] = a[j + 1]; a[j + 1] = t; } printf("%d%d%d", a[0], a[1], a[2]); ?
सही उत्तर: ख) 431
This is bubble sort that swaps when a[j] < a[j + 1], so it sorts in descending order: 4, 3, 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int n = 9875, s; while (n > 9) { s = 0; while (n) { s += n % 10; n /= 10; } n = s; } printf("%d", n); ?
सही उत्तर: घ) 2
The digit sum of 9875 is 29, of 29 is 11, and of 11 is 2; the loop stops at a single digit (the digital root).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
A common rounding trick is used in C: printf("%d", (int)(5.0 / 2 + 0.5));. Which value is displayed?
सही उत्तर: घ) 3
5.0 / 2 = 2.5, plus 0.5 gives 3.0, and the cast to int gives 3 (a common rounding trick).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char *s = "programming"; printf("%.4s", s + 3); ?
सही उत्तर: क) gram
s + 3 points to "gramming" and the precision .4 prints only its first 4 characters.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
A two-dimensional C array is initialised with a flat list: int a[2][3] = {1, 2, 3, 4, 5, 6};. What does printf("%d", a[1][1] + **a); then print?
सही उत्तर: क) 6
Rows are filled in order, so a[1][1] = 5, and **a is a[0][0] = 1; 5 + 1 = 6.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।