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
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; सच लौटें;} कोउट
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) All even. Output: 1.
व्याख्या (हिन्दी) सब सम. आउटपुट: 1.
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
A
4321 4321
B
1234 1234
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Reversed: 4321. Output: 4321.
व्याख्या (हिन्दी) उलटा: 4321. आउटपुट: 4321.
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
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.
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
A
10 10
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) racecar=palindrome=1; hello=not=0. Output: 10.
व्याख्या (हिन्दी) रेसकार=पैलिंड्रोम=1; नमस्ते=नहीं=0. आउटपुट: 10.
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]
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 is at index 4. Output: 4.
व्याख्या (हिन्दी) 5 सूचकांक 4 पर है। आउटपुट: 4।
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
A
20 20
B
33 33
C
Compile error संकलन त्रुटि
D
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.
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
A
1010 1010
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10 in binary=1010. Output: 1010.
व्याख्या (हिन्दी) बाइनरी में 10=1010. आउटपुट: 1010.
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
A
8 8
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4+4=8. Output: 8.
व्याख्या (हिन्दी) 4+4=8. आउटपुट: 8.
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 आउटपुट क्या है: ऑटो करी = [] (इंट ए) {रिटर्न [ए] (इंट बी) {रिटर्न [ए, बी] (इंट सी) {रिटर्न ए + बी + सी;};};}; कॉउट
A
6 6
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3=6. Output: 6.
व्याख्या (हिन्दी) 1+2+3=6. आउटपुट: 6.
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
A
37 37
B
7 7
C
Compile error संकलन त्रुटि
D
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 ही लौटाता है
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
A
3 3
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2,4,5 are positive. Count=3. Output: 3.
व्याख्या (हिन्दी) 2,4,5 सकारात्मक हैं. गिनती=3. आउटपुट: 3.
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
A
16 16
B
15 15
C
Compile error संकलन त्रुटि
D
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.
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);}; अदालत
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
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
A
21 21
B
10 10
C
Compile error संकलन त्रुटि
D
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.
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;}); अदालत
A
2536 2536
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
25 36 25 36
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(5)=25, sq(6)=36. Output: 2536.
व्याख्या (हिन्दी) वर्ग(5)=25, वर्ग(6)=36. आउटपुट: 2536.
106–120 of 132