प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
What is printed by the C code: int n = 100, c = 0; while (n % 2 == 0) { n /= 2; c++; } printf("%d %d", c, n); ?
सही उत्तर: ख) 2 25
100 / 2 = 50 and 50 / 2 = 25; 25 is odd, so the loop stops after 2 divisions with n = 25.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i, c = 0; for (i = 1; i <= 100; i++) if (i % 3 == 0 && i % 5 == 0) c++; printf("%d", c); ?
सही उत्तर: ग) 6
Numbers divisible by both 3 and 5 are multiples of 15: 15, 30, 45, 60, 75, 90, so there are 6.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a[5] = {1, 2, 3, 4, 5}; int *p = a + 4; printf("%d", *p - *(p - 3)); ?
सही उत्तर: ख) 3
p points to a[4] = 5 and p - 3 points to a[1] = 2, so 5 - 2 = 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a = 10, b = 20; int *p = &a, *q = &b; *p = *p + *q; p = q; *p = 5; printf("%d %d", a, b); ?
सही उत्तर: घ) 30 5
First a becomes 10 + 20 = 30; then p is made to point to b, so *p = 5 changes b to 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C, given void p(int n) { if (n) { printf("%d", n); p(n - 1); printf("%d", n); } } what does the call p(3) print?
सही उत्तर: ग) 321123
Each call prints n before recursing and again after returning, so the output is 3 2 1 on the way down and 1 2 3 on the way back up.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a[] = {3, 1, 4, 1, 5, 9}; printf("%d", (int)(sizeof(a) / sizeof(a[0]))); ?
सही उत्तर: ग) 6
sizeof(a) is the size of the whole array and sizeof(a[0]) the size of one element, so their ratio is the number of elements, 6.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
On an ASCII system, what does the C statement printf("%d", 'A' < 'a'); print?
सही उत्तर: ख) 1
'A' has code 65 and 'a' has code 97, so the comparison is true and a relational expression yields 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Evaluate the C expression 6 & ~2 (bitwise AND with a bitwise NOT).
सही उत्तर: घ) 4
~2 clears only bit 1; 6 is binary 110, and clearing bit 1 gives 100, which is 4.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a = 5; int b = a << 1 | 1; printf("%d", b); ?
सही उत्तर: ग) 11
<< has higher precedence than |: 5 << 1 = 10 (binary 1010), and 10 | 1 = 11 (binary 1011).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: char s[] = "programming"; int i, c = 0; for (i = 0; s[i]; i++) if (s[i] == 'm') c++; printf("%d", c); ?
सही उत्तर: ख) 2
The loop stops at the terminating '\0'; the letter 'm' occurs twice in "programming".
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।