OOP Using C++ — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye

📚 132 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
132 questions
91
EN + हिं
GB What is the output: auto fib=[]()->generator{int a=0,b=1;for(;;){co_yield a;tie(a,b)=make_pair(b,a+b);}}; auto g=fib(); cout<{});
IN आउटपुट क्या है: auto fib=[]()->generator{int a=0,b=1;for(;;){co_yield a;tie(a,b)=make_pair(b,a+b);}}; ऑटो जी=फ़ाइब(); अदालत
A
Compile error (no generator) संकलन त्रुटि (कोई जनरेटर नहीं)
B
21 21
C
33 33
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fibonacci: 0,1,1,2,3,5,8,13. Sum=33. Output: 33.
व्याख्या (हिन्दी) फाइबोनैचि: 0,1,1,2,3,5,8,13. योग=33. आउटपुट: 33.
92
EN + हिं
GB What is the output: int f(int a,int b,int c){return (a>b?a:b)>c?(a>b?a:b):c;} cout<
IN आउटपुट क्या है: int f(int a,int b,int c){return (a>b?a:b)>c?(a>b?a:b):c;} cout
A
7 7
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) max(3,7)=7; 7>5=7. Output: 7.
व्याख्या (हिन्दी) अधिकतम(3,7)=7; 7>5=7. आउटपुट: 7.
93
EN + हिं
GB What is 'std::execution::par_unseq'?
IN 'std::execution::par_unseq' क्या है?
A
Parallel and vectorized algorithm execution समानांतर और वेक्टरकृत एल्गोरिदम निष्पादन
B
Same as par बराबर के समान
C
GPU execution जीपीयू निष्पादन
D
Single thread एकल धागा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) par_unseq allows both parallelism and SIMD vectorization; most aggressive optimization.
व्याख्या (हिन्दी) par_unseq समानता और SIMD वैश्वीकरण दोनों की अनुमति देता है; सबसे आक्रामक अनुकूलन.
94
EN + हिं
GB What is the output: int f(int x){return x*(x+1)/2;} int g(int x){return f(x)-f(x/2);} cout<
IN आउटपुट क्या है: int f(int x){return x*(x+1)/2;} int g(int x){return f(x)-f(x/2);} cout
A
40 40
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(10)=55; f(5)=15. g(10)=55-15=40. Output: 40.
व्याख्या (हिन्दी) f(10)=55; एफ(5)=15. जी(10)=55-15=40. आउटपुट: 40.
95
EN + हिं
GB What is the output: int f(int x,int n){return n?f(x,n-1)+x:0;} cout<
IN आउटपुट क्या है: int f(int x,int n){return n?f(x,n-1)+x:0;} cout
A
20 20
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(4,5)=f(4,4)+4=...=0+4+4+4+4+4=20. Output: 20.
व्याख्या (हिन्दी) f(4,5)=f(4,4)+4=...=0+4+4+4+4+4=20. आउटपुट: 20.
96
EN + हिं
GB What is the output: int f(int x,int y){return x==0?y:f(x-1,y+1);} cout<
IN आउटपुट क्या है: int f(int x,int y){return x==0?y:f(x-1,y+1);} cout
A
8 8
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(3,5)=f(2,6)=f(1,7)=f(0,8)=8. Output: 8.
व्याख्या (हिन्दी) f(3,5)=f(2,6)=f(1,7)=f(0,8)=8. आउटपुट: 8.
97
EN + हिं
GB What is the output: template struct Fact{static constexpr long long v=N*Fact::v;}; template<> struct Fact<0>{static constexpr long long v=1;}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट struct Fact{static constexpr long long v=N*Fact::v;}; टेम्पलेट संरचना तथ्य{static constexpr long long v=1;}; अदालत
A
3628800 3628800
B
120 120
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10!=3628800. Output: 3628800.
व्याख्या (हिन्दी) 10!=3628800. आउटपुट: 3628800.
98
EN + हिं
GB What is the output: auto negate=[](auto f){return [=](auto...args){return !f(args...);};}; auto isEven=[](int x){return x%2==0;}; cout<
IN आउटपुट क्या है: auto negate=[](auto f){return [=](auto...args){return !f(args...);};}; ऑटो isEven=[](int x){रिटर्न x%2==0;}; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) isEven(3)=false; !false=true=1. Output: 1.
व्याख्या (हिन्दी) सम(3)=झूठा है; !झूठा=सत्य=1. आउटपुट: 1.
99
EN + हिं
GB What is the output: int f(int x){return x%2?x:f(x/2);} cout<
IN आउटपुट क्या है: int f(int x){return x%2?x:f(x/2);} cout
A
3 3
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 12->6->3(odd). Output: 3.
व्याख्या (हिन्दी) 12->6->3(विषम)। आउटपुट: 3.
100
EN + हिं
GB What is the output: int f(int x){return x<10?f(x+1)+x:x;} cout<
IN आउटपुट क्या है: int f(int x){return x
A
50 50
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(5)=f(6)+5=f(7)+6+5=...=10+9+8+7+6+5=45. Wait: f(5)=f(6)+5; f(6)=f(7)+6; f(7)=f(8)+7; f(8)=f(9)+8; f(9)=f(10)+9; f(10)=10. f(9)=19; f(8)=27; f(7)=34; f(6)=40; f(5)=45. Output: 45.
व्याख्या (हिन्दी) f(5)=f(6)+5=f(7)+6+5=...=10+9+8+7+6+5=45. रुको: f(5)=f(6)+5; f(6)=f(7)+6; f(7)=f(8)+7; f(8)=f(9)+8; f(9)=f(10)+9; एफ(10)=10. f(9)=19; f(8)=27; f(7)=34; f(6)=40; एफ(5)=45. आउटपुट: 45.
101
EN + हिं
GB What is the output: auto pipe=[](auto...fns){return [=](auto x){(...,(x=fns(x)));return x;};}; auto fn=pipe([](int x){return x+1;},[](int x){return x*2;},[](int x){return x-3;}); cout<
IN आउटपुट क्या है: ऑटो पाइप=[](ऑटो...एफएनएस){रिटर्न [=](ऑटो x){(...,(x=fns(x)));रिटर्न x;};}; ऑटो fn=पाइप([](int x){रिटर्न x+1;},[](int x){रिटर्न x*2;},[](int x){रिटर्न x-3;}); अदालत
A
9 9
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5+1=6; 6*2=12; 12-3=9. Output: 9.
व्याख्या (हिन्दी) 5+1=6; 6*2=12; 12-3=9. आउटपुट: 9.
102
EN + हिं
GB What is the output: int f(int x){if(x<0)return f(-x); return x<10?x:f(x%10)+f(x/10);} cout<
IN आउटपुट क्या है: int f(int x){if(x
A
6 6
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(-123)=f(123)=f(3)+f(12)=3+f(2)+f(1)=3+2+1=6. Output: 6.
व्याख्या (हिन्दी) f(-123)=f(123)=f(3)+f(12)=3+f(2)+f(1)=3+2+1=6. आउटपुट: 6.
103
EN + हिं
GB What is the output: int f(int x,int y){return x%y==0?x/y:f(x,y-1);} cout<
IN आउटपुट क्या है: int f(int x,int y){return x%y==0?x/y:f(x,y-1);} cout
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 12%5=2, 12%4=0: return 12/4=3. Output: 3.
व्याख्या (हिन्दी) 12%5=2, 12%4=0: वापसी 12/4=3। आउटपुट: 3.
104
EN + हिं
GB What is the output: auto f=[](int n)->string{return n==0?"zero":n>0?"pos":"neg";}; cout<
IN आउटपुट क्या है: auto f=[](int n)->string{return n==0?"zero":n>0?"pos":"neg";}; अदालत
A
poszero neg सकारात्मक नकारात्मक
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
positive सकारात्मक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(5)=pos,f(0)=zero,f(-3)=neg. Output: poszeroneg.
व्याख्या (हिन्दी) f(5)=स्थिति,f(0)=शून्य,f(-3)=नकारात्मक. आउटपुट: पॉज़ज़ेरोनग।
105
EN + हिं
GB What is the output: int f(int a,int b,int c){return a>b?(a>c?a:c):(b>c?b:c);} cout<
IN आउटपुट क्या है: int f(int a,int b,int c){return a>b?(a>c?a:c):(b>c?b:c);} cout
A
7 7
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=3,b=7,c=5. a>b false: b>c?b:c=7. Output: 7.
व्याख्या (हिन्दी) ए=3,बी=7,सी=5. a>b गलत: b>c?b:c=7. आउटपुट: 7.
91–105 of 132