Data Structures and Algorithms — MCQ Practice

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

📚 1018 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
1018 questions
526
EN + हिं
GB The output of: int x=0; function f=[&](int n){return n<=0?x:(x+=n,f(n-1));}; cout<
IN का आउटपुट: int x=0; फ़ंक्शन f=[&](int n){रिटर्न n
A
15 15
B
5 5
C
10 10
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Recursive lambda via std::function: 5+4+3+2+1=15.
व्याख्या (हिन्दी) std::function के माध्यम से पुनरावर्ती लैम्ब्डा: 5+4+3+2+1=15।
527
EN + हिं
GB What is the output: struct A{int x; A(int x):x(x){} A(A&&a):x(move(a.x)){cout<<"M";} }; A a(1); A b(move(a));
IN आउटपुट क्या है: struct A{int x; A(int x):x(x){} A(A&&a):x(move(a.x)){cout
A
M printed एम मुद्रित
B
No output उत्पादन नही
C
Error गलती
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Move constructor called; prints M.
व्याख्या (हिन्दी) मूव कंस्ट्रक्टर को बुलाया गया; एम प्रिंट करता है
528
EN + हिं
GB What is the output: int x=10; auto f=[=]()mutable->int&{return x;}; f()=20; cout<
IN आउटपुट क्या है: int x=10; ऑटो f=[=]()mutable->int&{return x;}; एफ()=20; अदालत
A
20 20
B
10 10
C
Error गलती
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lambda captures by value; returning reference to copy; original x unchanged.
व्याख्या (हिन्दी) लैम्ब्डा मूल्य के आधार पर कब्जा करता है; प्रतिलिपि का संदर्भ लौटाना; मूल x अपरिवर्तित.
529
EN + हिं
GB The output of: int x=10; auto f=[&x]()->int&{return x;}; f()=20; cout<
IN का आउटपुट: int x=10; ऑटो f=[&x]()->int&{return x;}; एफ()=20; अदालत
A
10 10
B
20 20
C
Error गलती
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lambda captures x by reference; f()=20 modifies original x.
व्याख्या (हिन्दी) लैम्ब्डा संदर्भ द्वारा x को कैप्चर करता है; f()=20 मूल x को संशोधित करता है।
530
EN + हिं
GB The output of: class C{public:int operator()(int x){return x*x;} }; C sq; cout<
IN इसका आउटपुट: वर्ग C{सार्वजनिक:int ऑपरेटर()(int x){रिटर्न x*x;} }; सी वर्ग; अदालत
A
2516 2516
B
254 254
C
25 16 25 16
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(5)=25; sq(2)=4; sq(4)=16; 25 then 16: 2516.
व्याख्या (हिन्दी) वर्ग(5)=25; वर्ग(2)=4; वर्ग(4)=16; 25 फिर 16:2516.
531
EN + हिं
GB What is the output: auto curry=[](int a){return [a](int b){return a+b;};};cout<
IN आउटपुट क्या है: auto curry=[](int a){return [a](int b){return a+b;};};cout
A
12 12
B
7 7
C
3 3
D
4 4
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) curry(3) returns lambda that adds 3; called with 4: 3+4=7.
व्याख्या (हिन्दी) करी(3) लैम्ब्डा लौटाता है जो 3 जोड़ता है; 4:3+4=7 के साथ बुलाया गया।
532
EN + हिं Easy
GB What is currying in functional programming?
IN कार्यात्मक प्रोग्रामिंग में करींग क्या है?
A
Merging functions कार्यों का विलय
B
Transforming multi-argument function into sequence of single-argument functions बहु-तर्क फ़ंक्शन को एकल-तर्क कार्यों के अनुक्रम में बदलना
C
Recursion pattern प्रत्यावर्तन पैटर्न
D
Template pattern टेम्पलेट पैटर्न
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Currying: f(a,b) becomes f(a)(b).
व्याख्या (हिन्दी) करी: f(a,b) f(a)(b) बन जाता है।
533
EN + हिं
GB The output of: vector v={1,2,3,4,5}; auto it=partition(v.begin(),v.end(),[](int x){return x%2==0;}); cout<
IN का आउटपुट: वेक्टर v={1,2,3,4,5}; ऑटो आईटी=विभाजन(v.begin(),v.end(),[](int x){रिटर्न x%2==0;}); अदालत
A
2 2
B
3 3
C
4 4
D
5 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Even elements {2,4} moved to front; partition point at index 2.
व्याख्या (हिन्दी) यहां तक ​​कि तत्व {2,4} भी सामने चले गए; सूचकांक 2 पर विभाजन बिंदु।
534
EN + हिं
GB The output of: vector v={1,2,3,4,5}; rotate(v.begin(),v.begin()+3,v.end()); for(auto x:v)cout<
IN का आउटपुट: वेक्टर v={1,2,3,4,5}; रोटेट(v.begin(),v.begin()+3,v.end()); for(ऑटो x:v)cout
A
45123 45123
B
12345 12345
C
34512 34512
D
54321 54321
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Rotate left by 3: {4,5,1,2,3}.
व्याख्या (हिन्दी) 3 से बाएँ घुमाएँ: {4,5,1,2,3}।
535
EN + हिं
GB The output of: int arr[]={3,1,4,1,5}; cout<<*max_element(arr,arr+5)<<" "<<*min_element(arr,arr+5);
IN इसका आउटपुट: int arr[]={3,1,4,1,5}; अदालत
A
5 1 5 1
B
3 1 3 1
C
4 1 4 1
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Max=5, Min=1.
व्याख्या (हिन्दी) अधिकतम=5, न्यूनतम=1.
536
EN + हिं
GB The output of: int a=5,b=3; cout<
IN का आउटपुट: int a=5,b=3; अदालत
A
15 15
B
8 8
C
2 2
D
5 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Values: 5,3,8,15,2; max=15.
व्याख्या (हिन्दी) मान: 5,3,8,15,2; अधिकतम=15.
537
EN + हिं
GB The output of: cout<
IN का आउटपुट: कॉउट
A
15 15
B
10 10
C
1 1
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 15 > 10 (upper bound); clamped to 10.
व्याख्या (हिन्दी) 15 > 10 (ऊपरी सीमा); 10 पर जकड़ दिया गया।
538
EN + हिं
GB The output of: cout<
IN का आउटपुट: कॉउट
A
1 1
B
-5 -5
C
10 10
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) -5 < 1 (lower bound); clamped to 1.
व्याख्या (हिन्दी) -5 <1 (निचली सीमा); 1 से जकड़ा हुआ।
539
EN + हिं
GB The output of: int a=3,b=5; cout<<(ab?a:b);
IN का आउटपुट: int a=3,b=5; अदालत
A
3 5 3 5
B
5 3 5 3
C
3 3 3 3
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min(5)=3; max(5)=5.
व्याख्या (हिन्दी) मिनट(5)=3; अधिकतम(5)=5.
540
EN + हिं
GB What is the output: int n=10; int bits=0; while(n){bits+=(n&1); n>>=1;} cout<
IN आउटपुट क्या है: int n=10; int बिट्स=0; जबकि(एन){बिट्स+=(एन&1); n>>=1;} कोउट
A
2 2
B
3 3
C
4 4
D
1 1
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10=1010 has 2 set bits.
व्याख्या (हिन्दी) 10=1010 में 2 सेट बिट हैं।
526–540 of 1018