प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Determine the output of this C++ fragment: int c = 0; auto f = [c]() mutable { return ++c; }; f(); f(); cout << f() << c;
सही उत्तर: ग) 30
The lambda captures its own copy of c; mutable lets that copy change across calls (1, 2, 3), while the outer c stays 0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: int a = 7, b = 2; cout << a / b << a % b << (double)a / b;
सही उत्तर: ख) 313.5
Integer division gives 3, the remainder is 1, and casting a to double gives 3.5; they are printed one after another.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: map<string, int> m{{"b", 2}, {"a", 1}}; m["c"]; cout << m.size() << m["c"];
सही उत्तर: क) 30
Using operator[] with a missing key inserts it with a value-initialised int (0), so the map now has 3 entries and m["c"] is 0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: string s = "banana"; cout << s.find("an") << s.rfind("an");
सही उत्तर: घ) 13
find returns the first position of "an" (1) and rfind the last one (3).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: vector<int> v{5, 1, 4}; v.insert(v.begin() + 1, 2, 9); for (int x : v) cout << x;
सही उत्तर: ग) 59914
insert(pos, 2, 9) inserts two copies of 9 before index 1, giving 5 9 9 1 4.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given struct B { virtual string n() { return "B"; } }; struct D : B { string n() override { return "D"; } }; void v(B b) { cout << b.n(); } void r(B &b) { cout << b.n(); }, what is printed by D d; v(d); r(d); ?
सही उत्तर: ख) BD
Passing by value slices the D object into a plain B, so v prints B; passing by reference keeps dynamic binding, so r prints D.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: struct A { A() { cout << "D"; } A(const A&) { cout << "C"; } A& operator=(const A&) { cout << "="; return *this; } }; A a, b; b = a; A c = a;
सही उत्तर: क) DD=C
a and b use the default constructor (DD), b = a calls copy assignment (=), and A c = a is initialisation, so it calls the copy constructor (C).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: printf("%+d %+d", 5, -5);
सही उत्तर: घ) +5 -5
The + flag forces a sign to be printed for positive numbers as well as negative ones.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: printf("%.3f", 1.0 / 8);
सही उत्तर: ग) 0.125
1/8 = 0.125, and %.3f prints exactly three digits after the decimal point.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C fragment: int n = 6, f = 1; while (n > 1) f *= n, n -= 2; printf("%d", f);
सही उत्तर: ख) 48
The comma operator keeps both actions in the loop body: f = 6 * 4 * 2 = 48 (the double factorial of 6).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।