प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
How many times is n++ executed by: for (i = 0; i < 5; i++) for (j = i; j < 5; j++) n++; ?
सही उत्तर: ख) 15
The inner loop runs 5, 4, 3, 2 and 1 times for i = 0 to 4, giving 5 + 4 + 3 + 2 + 1 = 15.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int i, s = 0; for (i = 1; i <= 20; i += 4) s += i; printf("%d", s); ?
सही उत्तर: घ) 45
i takes the values 1, 5, 9, 13 and 17 (21 fails the test), and 1 + 5 + 9 + 13 + 17 = 45.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int a = 7, b = 3; printf("%d", a % b * b + a / b); ?
सही उत्तर: घ) 5
% and * have equal precedence and associate left to right: (7 % 3) * 3 = 3, and 7 / 3 = 2 (integer division), so 3 + 2 = 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Which sorting algorithm repeatedly picks the next element and inserts it into its correct place among the already sorted elements to its left?
सही उत्तर: ख) Insertion sort
Insertion sort grows a sorted prefix by inserting one new element at a time into its correct position.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Binary search (mid = (low + high) / 2, integer division) looks for 7 in the sorted array [1, 3, 5, 7, 9, 11, 13]. How many comparisons with array elements are needed to find 7?
सही उत्तर: ग) 1
With low = 0 and high = 6, mid is 3 and the element at index 3 is 7, so it is found at the first comparison.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Pseudocode: N = 6, F = 0; for K = 1 to N: if N mod K = 0 then F = F + K; print F. What is printed?
सही उत्तर: घ) 12
The loop adds the divisors of 6, which are 1, 2, 3 and 6, giving 12.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Pseudocode: S = 0, I = 1; while I <= 5 do S = S + I * I; I = I + 2; end; print S. What is printed?
सही उत्तर: क) 35
I takes the values 1, 3 and 5, so S = 1 + 9 + 25 = 35.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
The recurrence T(n) = 2T(n/2) + c, where c is a constant, has the solution:
सही उत्तर: क) O(n)
The recursion tree has about 2n nodes each doing constant work, so the total is linear (master theorem case 1).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Big-O notation, the running time f(n) = 3n^2 + 1000n + 50 log n is:
सही उत्तर: ख) O(n^2)
Big-O keeps only the fastest-growing term and drops constant factors, so n^2 dominates.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
The keys 10, 20, 5 and 30 are inserted one by one into an empty max-heap stored in an array. What is the array after the last insertion?
सही उत्तर: ग) [30, 20, 5, 10]
After 10, 20, 5 the heap is [20, 10, 5]; 30 is added at index 3, swapped with 10 and then with 20, giving [30, 20, 5, 10].
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।