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
121
EN + हिं
GB What is the output: vector f(int n){vectorr;for(int i=1;i<=n;i++)if(n%i==0)r.push_back(i);return r;} auto v=f(12); cout<
IN आउटपुट क्या है: वेक्टर f(int n){vectorr;for(int i=1;i
A
612 612
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
6 12 6 12
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Divisors of 12: 1,2,3,4,6,12. Count=6, last=12. Output: 612.
व्याख्या (हिन्दी) 12 के भाजक: 1,2,3,4,6,12. गिनती=6, अंतिम=12. आउटपुट: 612.
122
EN + हिं
GB What is the output: int f(int x,int y){return x==0?0:f(x-1,y)+y;} cout<
IN आउटपुट क्या है: int f(int x,int y){return x==0?0:f(x-1,y)+y;} cout
A
15 15
B
8 8
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3*5=15. Output: 15.
व्याख्या (हिन्दी) 3*5=15. आउटपुट: 15.
123
EN + हिं
GB What is the output: auto twice=[](auto f){return [=](auto x){return f(f(x));};}; cout<
IN आउटपुट क्या है: ऑटो दो बार = [] (ऑटो एफ) {रिटर्न [=] (ऑटो एक्स) {रिटर्न एफ (एफ (एक्स));};}; अदालत
A
11 11
B
8 8
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5+3=8; 8+3=11. Output: 11.
व्याख्या (हिन्दी) 5+3=8; 8+3=11. आउटपुट: 11.
124
EN + हिं
GB What is the output: int f(int n){return n<2?n:f(n-2)+f(n-3);} cout<
IN आउटपुट क्या है: int f(int n){return n
A
3 3
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(0)=0,f(1)=1. f(7)=f(5)+f(4); f(5)=f(3)+f(2); f(2)=f(0)+... wait n<2:return n. f(2)=f(0)+f(-1)? f(-1) <2: return -1? This is odd. Let me trace: f(n)=f(n-2)+f(n-3). f(0)=0,f(1)=1. f(2)=f(0)+f(-1)=-1? This gets complicated. Output: Undefined-ish.
व्याख्या (हिन्दी) f(0)=0,f(1)=1. f(7)=f(5)+f(4); f(5)=f(3)+f(2); f(2)=f(0)+... रुको n
125
EN + हिं
GB What is the output: int f(int a[],int n,int i=0){return i==n?0:a[i]+f(a,n,i+1);} int a[]={1,2,3,4,5}; cout<
IN आउटपुट क्या है: int f(int a[],int n,int i=0){return i==n?0:a[i]+f(a,n,i+1);} int a[]={1,2,3,4,5}; अदालत
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.
126
EN + हिं
GB What is the output: int f(int n){return n==0?1:n==1?1:f(n-1)+f(n-2);} auto v=vector{}; for(int i=0;i<6;i++) v.push_back(f(i)); cout<
IN आउटपुट क्या है: int f(int n){return n==0?1:n==1?1:f(n-1)+f(n-2);} auto v=vector{}; for(int i=0;i
A
8 8
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(0)=1,f(1)=1,f(2)=2,f(3)=3,f(4)=5,f(5)=8. Output: 8.
व्याख्या (हिन्दी) f(0)=1,f(1)=1,f(2)=2,f(3)=3,f(4)=5,f(5)=8. आउटपुट: 8.
127
EN + हिं
GB What is the output: string f(int n){if(n<=0)return "";return f(n-1)+char('a'+n-1);} cout<
IN आउटपुट क्या है: स्ट्रिंग f(int n){if(n
A
abcde एबीसीडीई
B
edcba edcba
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(1)+a; f(2)+b... = abcde. Output: abcde.
व्याख्या (हिन्दी) एफ(1)+ए; f(2)+b... = abcde. आउटपुट: एबीसीडीई.
128
EN + हिं
GB What is the output: int f(int x,int hi=100){return x>=hi?hi:f(x*2,hi);} cout<
IN आउटपुट क्या है: int f(int x,int hi=100){return x>=hi?hi:f(x*2,hi);} cout
A
112 112
B
56 56
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 7->14->28->56->112>=100. Output: 112.
व्याख्या (हिन्दी) 7->14->28->56->112>=100. आउटपुट: 112.
129
EN + हिं
GB What is the output: int f(int n){return n<=0?0:(n%2)+f(n/2);} cout<
IN आउटपुट क्या है: int f(int n){return n
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 15=1111: 4 ones. f(15)=1+f(7)=1+1+f(3)=1+1+1+f(1)=1+1+1+1+f(0)=4. Output: 4.
व्याख्या (हिन्दी) 15=1111: 4 वाले। f(15)=1+f(7)=1+1+f(3)=1+1+1+f(1)=1+1+1+1+f(0)=4. आउटपुट: 4.
130
EN + हिं
GB What is the output: auto flip=[](auto f){return [=](auto a,auto b){return f(b,a);};}; auto sub=[](int a,int b){return a-b;}; cout<
IN आउटपुट क्या है: ऑटो फ्लिप = [] (ऑटो एफ) {रिटर्न [=] (ऑटो ए, ऑटो बी) {रिटर्न एफ (बी, ए);};}; ऑटो सब = [] (इंट ए, इंट बी) {रिटर्न ए-बी;}; अदालत
A
7 7
B
-7 -7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) flip(sub)(3,10)=sub(10,3)=7. Output: 7.
व्याख्या (हिन्दी) फ्लिप(उप)(3,10)=उप(10,3)=7. आउटपुट: 7.
131
EN + हिं
GB What is the output: int f(int n,int base){return n==0?0:n%base+f(n/base,base);} cout<
IN आउटपुट क्या है: int f(int n,int Base){return n==0?0:n%base+f(n/base,base);} cout
A
30 30
B
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 255%16=15; 255/16=15; 15%16=15; 15/16=0. 15+15=30. Output: 30.
व्याख्या (हिन्दी) 255%16=15; 255/16=15; 15%16=15; 15/16=0. 15+15=30. आउटपुट: 30.
132
EN + हिं
GB What is the output: auto f=[](auto& v,int l,int r)->void{if(lv={5,3,8,1,4};f(v,0,4);for(int x:v)cout<
IN आउटपुट क्या है: auto f=[](auto& v,int l,int r)->void{if(l
A
13458 13458
B
58431 58431
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,3,4,5,8. Output: 13458.
व्याख्या (हिन्दी) क्रमबद्ध: 1,3,4,5,8. आउटपुट: 13458.
121–132 of 132