प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Determine the output of this C fragment: double s = 0; int i; for (i = 1; i <= 4; i++) s += 1.0 / i; printf("%.2f", s);
सही उत्तर: ग) 2.08
s = 1 + 0.5 + 0.3333 + 0.25 = 2.0833, printed with two decimals as 2.08.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given int f(int n) { return n <= 1 ? 1 : f(n - 1) + f(n - 2) + 1; }, what is printed by printf("%d", f(4)); ?
सही उत्तर: ख) 9
f(0) = f(1) = 1, f(2) = 1 + 1 + 1 = 3, f(3) = 3 + 1 + 1 = 5, f(4) = 5 + 3 + 1 = 9.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: float f; int c = 0; for (f = 0.5f; f < 3.0f; f += 0.5f) c++; printf("%d", c);
सही उत्तर: क) 5
f takes the exactly representable values 0.5, 1.0, 1.5, 2.0 and 2.5 before reaching 3.0, so the body runs 5 times.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: char s[] = "abc"; char *p = s; ++*p; p++; ++*p; printf("%s", s);
सही उत्तर: घ) bcc
++*p increments the character p points to: s[0] 'a' becomes 'b'; after p++, s[1] 'b' becomes 'c', giving "bcc".
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int a[3][2] = {1, 2, 3, 4, 5, 6}; printf("%d", a[2][0] - a[0][1]);
सही उत्तर: ग) 3
Filling row by row gives rows {1, 2}, {3, 4}, {5, 6}; a[2][0] = 5 and a[0][1] = 2, so 5 - 2 = 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: char names[3][10] = {"Ram", "Sita", "Gita"}; printf("%d %d", (int)sizeof(names), (int)strlen(names[1]));
सही उत्तर: ख) 30 4
The array has 3 rows of 10 chars, so sizeof is 30 bytes; names[1] is "Sita", whose length is 4.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: char a[] = "cat", b[] = "car"; printf("%d", strcmp(a, b) > 0);
सही उत्तर: क) 1
The strings first differ at the third character; 't' comes after 'r', so strcmp returns a positive value and the comparison gives 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int x = 2.99 * 2; printf("%d", x);
सही उत्तर: घ) 5
2.99 * 2 = 5.98, and converting a double to int truncates the fractional part, giving 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int a = 0, b = 0; if (a++ && b++) ; printf("%d %d", a, b);
सही उत्तर: ग) 1 0
a++ yields 0 (false), so && short-circuits and b++ is never evaluated; a is then 1 and b stays 0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int i, j, c = 0; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { if (j == i) break; c++; } printf("%d", c);
सही उत्तर: ख) 3
break leaves only the inner loop: c grows by 0 when i = 0, by 1 when i = 1 and by 2 when i = 2, total 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।