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
61
EN + हिं
GB What is the output: int f(int n){return n==1?1:f(n/2)+(n%2);} cout<
IN आउटपुट क्या है: int f(int n){return n==1?1:f(n/2)+(n%2);} cout
A
3 3
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(7)=f(3)+1=f(1)+1+1=1+1+1=3. Output: 3.
व्याख्या (हिन्दी) f(7)=f(3)+1=f(1)+1+1=1+1+1=3. आउटपुट: 3.
62
EN + हिं
GB What is 'std::compose' equivalent in C++?
IN C++ में 'std::compose' समतुल्य क्या है?
A
Not standard; use lambda chaining मानक नहीं; लैम्ब्डा चेनिंग का उपयोग करें
B
A range view एक रेंज दृश्य
C
A bind expression एक बंधी हुई अभिव्यक्ति
D
std::transform एसटीडी::परिवर्तन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++ has no std::compose; function composition done via lambdas: auto compose=[](auto f,auto g){return [=](auto x){return f(g(x));};};
व्याख्या (हिन्दी) C++ में कोई std::compose नहीं है; लैम्ब्डा के माध्यम से किया गया फ़ंक्शन संयोजन: ऑटो कंपोज़ = [] (ऑटो एफ, ऑटो जी) {रिटर्न [=] (ऑटो एक्स) {रिटर्न एफ (जी (एक्स));};};
63
EN + हिं
GB What is the output: int (*fp[3])(int)={[](int x){return x;}, [](int x){return x*2;}, [](int x){return x*3;}}; cout<
IN आउटपुट क्या है: int (*fp[3])(int)={[](int x){return x;}, [](int x){return x*2;}, [](int x){return x*3;}}; अदालत
A
15 15
B
10 10
C
5 5
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) fp[2]=x*3. fp[2](5)=15. Output: 15.
व्याख्या (हिन्दी) एफपी[2]=x*3. एफपी[2](5)=15। आउटपुट: 15.
64
EN + हिं
GB What is the output: int f(int x){return x*(x+1)*(x+2)/6;} cout<
IN आउटपुट क्या है: int f(int x){return x*(x+1)*(x+2)/6;} cout
A
20 20
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4*5*6/6=20. Output: 20.
व्याख्या (हिन्दी) 4*5*6/6=20. आउटपुट: 20.
65
EN + हिं
GB 'What is the output: int a=0; auto inc=[&](){a++;}; auto dec=[&](){a (1, 6, 75, 5, 4, 'What is the output: auto square=[](auto x){return x*x;}; cout<
IN 'आउटपुट क्या है: int a=0; ऑटो इंक=[&](){a++;}; ऑटो डिक=[&](){a (1, 6, 75, 5, 4, 'आउटपुट क्या है: ऑटो स्क्वायर = [] (ऑटो एक्स) {रिटर्न x*x;}; कॉउट
A
result=91. f(99)=91. Output: 91.', 0, '2026-05-25', '2026-05-25'), (1, 6, 75, 5, 4, 'What is the output: int f(int x){return x?f(x>>1)*2+(x&1):0;} cout<<f(10);', 'f reconstructs value?', '10', '10', '5', '5', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', 'f(10): rebuilds bits: f(10)=f(5)*2+0=10. Output: 10.', 0, '2026-05-25', '2026-05-25'), (1, 6, 75, 5, 4, 'What is the output: int f(int a,int b){return b?f(b,a%b):a;} cout<<f(100,75);', 'GCD(100,75)?', '25', '25', '75', '75', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', 'GCD(100,75)=GCD(75,25)=GCD(25,0)=25. Output: 25.', 0, '2026-05-25', '2026-05-25'), (1, 6, 75, 5, 4, 'What is the output: auto f=[]<typename T>(T x){return x+x;}; cout<<f(5)<<f(string("ab"));', 'C++20 template lambda?', '10ab', '10ab', 'Compile error', 'Compile error', 'Undefined', 'Undefined', '10abab', '10abab', NULL, 'option_d', 'C++20 template lambda: f(5)=10 परिणाम=91. एफ(99)=91. आउटपुट: 91.', 0, '2026-05-25', '2026-05-25'), (1, 6, 75, 5, 4, 'आउटपुट क्या है: int f(int x){return x?f(x>>1)*2+(x&1):0;} cout
B
2 2
C
4 4
D
2}; cout<<a[3];', 'Partial init: a[3]?', '0', '0', 'Garbage', 'Garbage', 'Undefined', 'Undefined', 'Compile error', 'Compile error', NULL, 'option_a', 'Remaining elements zero-initialized. a[3]=0. Output: 0.', 0, '2026-05-25', '2026-05-25'), (1, 6, 76, 6, 4, 'What is the output: int a[]={1 2}; अदालत
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3
व्याख्या (हिन्दी) 3
66
EN + हिं
GB What is the output: auto square=[](auto x){return x*x;}; cout<
IN आउटपुट क्या है: ऑटो वर्ग=[](ऑटो x){रिटर्न x*x;}; अदालत
A
162.25 162.25
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
16 2.25 16 2.25
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) square(4)=16, square(1.5)=2.25. Output: 162.25.
व्याख्या (हिन्दी) वर्ग(4)=16, वर्ग(1.5)=2.25. आउटपुट: 162.25.
67
EN + हिं
GB What is the output: int f(int x){if(x>100) return x-10; return f(f(x+11));} cout<
IN आउटपुट क्या है: int f(int x){if(x>100) return x-10; return f(f(x+11));} cout
A
91 91
B
99 99
C
100 100
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) McCarthy 91: for n<=100, result=91. f(99)=91. Output: 91.
व्याख्या (हिन्दी) मैक्कार्थी 91: एन के लिए
68
EN + हिं
GB What is the output: int f(int x){return x?f(x>>1)*2+(x&1):0;} cout<
IN आउटपुट क्या है: int f(int x){return x?f(x>>1)*2+(x&1):0;} cout
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(10): rebuilds bits: f(10)=f(5)*2+0=10. Output: 10.
व्याख्या (हिन्दी) f(10): बिट्स का पुनर्निर्माण करता है: f(10)=f(5)*2+0=10। आउटपुट: 10.
69
EN + हिं
GB What is the output: int f(int a,int b){return b?f(b,a%b):a;} cout<
IN आउटपुट क्या है: int f(int a,int b){return b?f(b,a%b):a;} cout
A
25 25
B
75 75
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(100,75)=GCD(75,25)=GCD(25,0)=25. Output: 25.
व्याख्या (हिन्दी) जीसीडी(100,75)=जीसीडी(75,25)=जीसीडी(25,0)=25। आउटपुट: 25.
70
EN + हिं
GB What is the output: auto f=[](T x){return x+x;}; cout<
IN आउटपुट क्या है: auto f=[](T x){return x+x;}; अदालत
A
10ab 10ab
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
10abab 10अबाब
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++20 template lambda: f(5)=10, f("ab")=string+string=abab. Output: 10abab.
व्याख्या (हिन्दी) C++20 टेम्प्लेट लैम्ब्डा: f(5)=10, f("ab")=स्ट्रिंग+स्ट्रिंग=अबाब। आउटपुट: 10abab.
71
EN + हिं
GB What is the output: int f(int n){return n<=0?0:n+f(n-2);} cout<
IN आउटपुट क्या है: int f(int n){return n
A
21 21
B
9 9
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(5)=9,f(6)=12. 9+12=21. Output: 21.
व्याख्या (हिन्दी) f(5)=9,f(6)=12. 9+12=21. आउटपुट: 21.
72
EN + हिं
GB What is the output: auto f=[](int x)->int{return x>1?x*f(x-1):1;}; cout<
IN आउटपुट क्या है: auto f=[](int x)->int{return x>1?x*f(x-1):1;}; अदालत
A
Compile error संकलन त्रुटि
B
24 24
C
4 4
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lambda can't call itself by name (f is not captured). Compile error.
व्याख्या (हिन्दी) लैम्ब्डा खुद को नाम से नहीं बुला सकता (एफ कैप्चर नहीं किया गया है)। संकलन त्रुटि.
73
EN + हिं
GB What is 'std::function' recursive pattern?
IN 'std::function' पुनरावर्ती पैटर्न क्या है?
A
std::function<int(int)> f; f=[&f](int n){return n<=1?1:n*f(n-1);} std::फ़ंक्शन f; f=[&f](int n){रिटर्न n
B
Not possible संभव नहीं
C
Only with templates केवल टेम्पलेट्स के साथ
D
A design pattern एक डिज़ाइन पैटर्न
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Using std::function and capturing by reference allows self-referential lambdas.
व्याख्या (हिन्दी) std::function का उपयोग करना और संदर्भ द्वारा कैप्चर करना स्व-संदर्भित लैम्ब्डा की अनुमति देता है।
74
EN + हिं
GB What is the output: int f(int x){return x;} float f(float x){return x;} double f(double x){return x;} cout<
IN आउटपुट क्या है: int f(int x){रिटर्न x;} फ्लोट f(फ्लोट x){रिटर्न x;} डबल f(डबल x){रिटर्न x;} कॉउट
A
4 4
B
8 8
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1 is int literal; f(int) called; sizeof(int)=4. Output: 4.
व्याख्या (हिन्दी) 1 पूर्णांक शाब्दिक है; f(int) कहा जाता है; sizeof(int)=4. आउटपुट: 4.
75
EN + हिं
GB What is the output: int f(int x,int y){return x*y;} int f(int x){return x*x;} cout<
IN आउटपुट क्या है: int f(int x,int y){return x*y;} int f(int x){return x*x;} cout
A
1612 1612
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
16 12 16 12
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(4)=4*4=16; f(3,4)=3*4=12. Output: 1612.
व्याख्या (हिन्दी) f(4)=4*4=16; f(3,4)=3*4=12. आउटपुट: 1612.
61–75 of 132