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

Question 106

EN + हिं
GB What is the output: template bool all(vectorv,functionp){for(T x:v) if(!p(x)) return false; return true;} cout<({2,4,6},[](int x){return x%2==0;});
IN आउटपुट क्या है: template bool all(vectorv,functionp){for(T x:v) if(!p(x)) return false; सच लौटें;} कोउट
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) All even. Output: 1.
व्याख्या (हिन्दी) सब सम. आउटपुट: 1.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 107

EN + हिं
GB What is the output: int f(int n){int r=0; while(n>0){r=r*10+n%10;n/=10;} return r;} cout<
IN आउटपुट क्या है: int f(int n){int r=0; while(n>0){r=r*10+n%10;n/=10;} return r;} cout
4321 4321
1234 1234
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Reversed: 4321. Output: 4321.
व्याख्या (हिन्दी) उलटा: 4321. आउटपुट: 4321.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 108

EN + हिं
GB What is the output: int f(int n){return n==0?0:n%10+f(n/10);} cout<
IN आउटपुट क्या है: int f(int n){return n==0?0:n%10+f(n/10);} cout
15 15
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) 1+2+3+4+5=15. आउटपुट: 15.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 109

EN + हिं
GB What is the output: bool f(string s){int n=s.size();for(int i=0;i
IN आउटपुट क्या है: bool f(string s){int n=s.size();for(int i=0;i
10 10
11 11
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) racecar=palindrome=1; hello=not=0. Output: 10.
व्याख्या (हिन्दी) रेसकार=पैलिंड्रोम=1; नमस्ते=नहीं=0. आउटपुट: 10.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 110

EN + हिं
GB What is the output: int f(vector&v,int l,int r){if(l>r)return -1;int m=(l+r)/2;return v[m]<5?f(v,m+1,r):v[m]==5?m:f(v,l,m-1);} vectorv={1,2,3,4,5,6,7}; cout<
IN आउटपुट क्या है: int f(vector&v,int l,int r){if(l>r)return -1;int m=(l+r)/2;return v[m]
4 4
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 is at index 4. Output: 4.
व्याख्या (हिन्दी) 5 सूचकांक 4 पर है। आउटपुट: 4।
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Functions" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 111

EN + हिं
GB What is the output: int f(int x){return x<=1?x:f(x-1)+f(x-2);} int g(int n){int s=0;for(int i=0;i
IN आउटपुट क्या है: int f(int x){return x
20 20
33 33
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+1+1+2+3+5+8=20. Output: 20.
व्याख्या (हिन्दी) 0+1+1+2+3+5+8=20. आउटपुट: 20.
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Functions" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 112

EN + हिं
GB What is the output: string f(int n){if(n==0)return "0";string r="";while(n){r=char('0'+n%2)+r;n/=2;} return r;} cout<
IN आउटपुट क्या है: स्ट्रिंग f(int n){if(n==0)return "0";string r=""; while(n){r=char('0'+n%2)+r;n/=2;} return r;} cout
1010 1010
10 10
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10 in binary=1010. Output: 1010.
व्याख्या (हिन्दी) बाइनरी में 10=1010. आउटपुट: 1010.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 113

EN + हिं
GB What is the output: int f(int a,int b){return a>b?a-b:b-a;} cout<
IN आउटपुट क्या है: int f(int a,int b){return a>b?a-b:b-a;} cout
8 8
4 4
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4+4=8. Output: 8.
व्याख्या (हिन्दी) 4+4=8. आउटपुट: 8.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 114

EN + हिं
GB What is the output: auto curry=[](int a){return [a](int b){return [a,b](int c){return a+b+c;};};};cout<
IN आउटपुट क्या है: ऑटो करी = [] (इंट ए) {रिटर्न [ए] (इंट बी) {रिटर्न [ए, बी] (इंट सी) {रिटर्न ए + बी + सी;};};}; कॉउट
6 6
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3=6. Output: 6.
व्याख्या (हिन्दी) 1+2+3=6. आउटपुट: 6.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 115

EN + हिं
GB What is the output: int f(int n,int d=10){return n
IN आउटपुट क्या है: int f(int n,int d=10){return n
37 37
7 7
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(37): 37>=10: f(27)+10; f(27):f(17)+10; f(17):f(7)+10; f(7)=7. Total=7+10+10+10=37. Output: 37. Hmm: returns n itself if n
व्याख्या (हिन्दी) f(37): 37>=10: f(27)+10; एफ(27):एफ(17)+10; एफ(17):एफ(7)+10; एफ(7)=7. कुल=7+10+10+10=37. आउटपुट: 37. हम्म: यदि n है तो n ही लौटाता है
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 116

EN + हिं
GB What is the output: int count_if_positive(vectorv){return count_if(v.begin(),v.end(),[](int x){return x>0;});} cout<
IN आउटपुट क्या है: int count_if_positive(vectorv){return count_if(v.begin(),v.end(),[](int x){return x>0;});} cout
3 3
2 2
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2,4,5 are positive. Count=3. Output: 3.
व्याख्या (हिन्दी) 2,4,5 सकारात्मक हैं. गिनती=3. आउटपुट: 3.
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Functions" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 117

EN + हिं
GB What is the output: int f(int x){return x*(x-1)/2;} cout<
IN आउटपुट क्या है: int f(int x){return x*(x-1)/2;} cout
16 16
15 15
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) T(5)=10, T(4)=6. 10+6=16. Output: 16.
व्याख्या (हिन्दी) टी(5)=10, टी(4)=6. 10+6=16. आउटपुट: 16.
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Functions" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 118

EN + हिं
GB What is the output: auto f=[](auto v){return accumulate(v.begin(),v.end(),0);}; cout<
IN आउटपुट क्या है: ऑटो f=[](ऑटो v){रिटर्न एक्युमेटेड(v.begin(),v.end(),0);}; अदालत
15 15
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 119

EN + हिं
GB What is the output: int f(int n){if(n<=0)return 0;return f(n-1)*2+(n%2);}cout<
IN आउटपुट क्या है: int f(int n){if(n
21 21
10 10
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(1)=f(0)*2+1=1; f(2)=f(1)*2+0=2; f(3)=2*2+1=5; f(4)=5*2+0=10; f(5)=10*2+1=21. Output: 21.
व्याख्या (हिन्दी) f(1)=f(0)*2+1=1; f(2)=f(1)*2+0=2; f(3)=2*2+1=5; f(4)=5*2+0=10; f(5)=10*2+1=21. आउटपुट: 21.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 120

EN + हिं
GB What is the output: auto memoise=[](auto f){map c; return [=](int n)mutable{if(!c.count(n))c[n]=f(n); return c[n];};}; auto sq=memoise([](int n){return n*n;}); cout<
IN आउटपुट क्या है: auto memoise=[](auto f){map c; वापसी [=](int n)mutable{if(!c.count(n))c[n]=f(n); वापसी सी[एन];};}; ऑटो sq=memoise([](int n){रिटर्न n*n;}); अदालत
2536 2536
Compile error संकलन त्रुटि
Undefined अपरिभाषित
25 36 25 36
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(5)=25, sq(6)=36. Output: 2536.
व्याख्या (हिन्दी) वर्ग(5)=25, वर्ग(6)=36. आउटपुट: 2536.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।