OOP Using C++ — MCQ Practice

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

📚 1915 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
1915 questions
1261
EN + हिं
GB What is the output: template auto sumAll(Args...args){return (args+...);} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो sumAll(Args...args){return (args+...);} cout
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) 1+2+3+4+5=15. आउटपुट: 15.
1262
EN + हिं
GB What is the output: int f(int x,int y=x){return x+y;}
IN आउटपुट क्या है: int f(int x,int y=x){return x+y;}
A
Compile error संकलन त्रुटि
B
Works fine बढ़िया काम करता है
C
Undefined अपरिभाषित
D
10 10
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default argument cannot refer to another parameter. Compile error.
व्याख्या (हिन्दी) डिफ़ॉल्ट तर्क किसी अन्य पैरामीटर को संदर्भित नहीं कर सकता. संकलन त्रुटि.
1263
EN + हिं
GB What is the output: int f(int x){return x%2?f(x-1)+1:0;} cout<
IN आउटपुट क्या है: int f(int x){return x%2?f(x-1)+1:0;} cout
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(7)=f(6)+1=0+1... wait: f(7)=7%2=1: f(6)+1=0+1=1. f(5)=f(4)+1=0+1=1. f(7)=f(6)+1. f(6)=0. f(7)=1. Hmm. Let me trace: f(7)=f(6)+1; f(6)=0; f(7)=1. But what about f(5)=f(4)+1=1? f(7)=f(6)+1=1. Output: 1.
व्याख्या (हिन्दी) f(7)=f(6)+1=0+1... प्रतीक्षा करें: f(7)=7%2=1: f(6)+1=0+1=1. f(5)=f(4)+1=0+1=1. f(7)=f(6)+1. एफ(6)=0. एफ(7)=1. हम्म। मुझे ट्रेस करने दीजिए: f(7)=f(6)+1; एफ(6)=0; एफ(7)=1. लेकिन f(5)=f(4)+1=1 के बारे में क्या? f(7)=f(6)+1=1. आउटपुट: 1.
1264
EN + हिं
GB What is the output: auto compose=[](auto f,auto g){return [=](auto x){return f(g(x));};}; auto fn=compose([](int x){return x+1;},[](int x){return x*2;}); cout<
IN आउटपुट क्या है: ऑटो कंपोज़ = [] (ऑटो एफ, ऑटो जी) {रिटर्न [=] (ऑटो एक्स) {रिटर्न एफ (जी (एक्स));};}; ऑटो fn=compose([](int x){return x+1;},[](int x){return x*2;}); अदालत
A
11 11
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) g(5)=10; f(10)=11. Output: 11.
व्याख्या (हिन्दी) जी(5)=10; एफ(10)=11. आउटपुट: 11.
1265
EN + हिं
GB What is the output: int f(int x){return x<=1?x:f(x/2)+(f((x+1)/2))+(x%2-1)?0:0;} cout<
IN आउटपुट क्या है: int f(int x){return x
A
8 8
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Tricky: f(8)=f(4)+f(4)+0=2*f(4); f(4)=f(2)+f(2)=2*f(2); f(2)=f(1)+f(1)=2. f(4)=4. f(8)=8. Output: 8.
व्याख्या (हिन्दी) पेचीदा: ​​f(8)=f(4)+f(4)+0=2*f(4); f(4)=f(2)+f(2)=2*f(2); f(2)=f(1)+f(1)=2. एफ(4)=4. एफ(8)=8. आउटपुट: 8.
1266
EN + हिं
GB What is 'std::invoke_r' in C++23?
IN C++23 में 'std::invoke_r' क्या है?
A
std::invoke with explicit return type conversion std::स्पष्ट रिटर्न प्रकार रूपांतरण के साथ प्रारंभ करें
B
Same as invoke आह्वान के समान
C
A cast एक निक्षेपण
D
A concept संप्रत्यय
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::invoke_r(f,args...) invokes and converts result to R.
व्याख्या (हिन्दी) std::invoke_r(f,args...) आह्वान करता है और परिणाम को R में परिवर्तित करता है।
1267
EN + हिं
GB What is the output: int x=5; auto f=[x](int y){return x+y;}; auto g=f; cout<
IN आउटपुट क्या है: int x=5; ऑटो f=[x](int y){रिटर्न x+y;}; ऑटो जी=एफ; अदालत
A
8 8
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) g is copy of f with x=5. g(3)=5+3=8. Output: 8.
व्याख्या (हिन्दी) g, x=5 के साथ f की प्रतिलिपि है। जी(3)=5+3=8. आउटपुट: 8.
1268
EN + हिं
GB What is the output: template auto id(T&& x)->T&&{return forward(x);} int a=5; cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो आईडी(टी&& एक्स)->टी&&{रिटर्न फॉरवर्ड(x);} int a=5; अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Address पता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) id(a) returns lvalue reference; cout<<5. Output: 5.
व्याख्या (हिन्दी) आईडी(ए) लैवैल्यू संदर्भ लौटाता है; अदालत
1269
EN + हिं
GB What is the output: int f(int x){return x?f(x/2)*2+(x&1):0;} cout<
IN आउटपुट क्या है: int f(int x){return x?f(x/2)*2+(x&1):0;} cout
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(10)=f(5)*2+0; f(5)=f(2)*2+1; f(2)=f(1)*2+0; f(1)=f(0)*2+1=1. f(2)=2. f(5)=5. f(10)=10. Output: 10.
व्याख्या (हिन्दी) f(10)=f(5)*2+0; f(5)=f(2)*2+1; f(2)=f(1)*2+0; f(1)=f(0)*2+1=1. एफ(2)=2. एफ(5)=5. एफ(10)=10. आउटपुट: 10.
1270
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.
1271
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.
1272
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 वैश्वीकरण दोनों की अनुमति देता है; सबसे आक्रामक अनुकूलन.
1273
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.
1274
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.
1275
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.
1261–1275 of 1915