Data Structures and Algorithms — MCQ Practice

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

📚 819 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
819 questions

Question 451

EN + हिं
GB What is the output: struct Pt{int x,y; Pt(int x,int y):x(x),y(y){} double dist(){return sqrt(x*x+y*y);}}; Pt p(4); cout<
IN आउटपुट क्या है: struct Pt{int x,y; Pt(int x,int y):x(x),y(y){} डबल डिस्ट(){रिटर्न sqrt(x*x+y*y);}}; पीटी पी(4); अदालत
5 5
7 7
25 25
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sqrt(9+16)=sqrt(25)=5.
व्याख्या (हिन्दी) sqrt(9+16)=sqrt(25)=5.
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 452

EN + हिं
GB The output of: class Ctr{int n=0; public: void inc(){n++;} int get(){return n;} }; Ctr c; c.inc(); c.inc(); c.inc(); cout<
IN इसका आउटपुट: क्लास Ctr{int n=0; सार्वजनिक: void inc(){n++;} int get(){return n;}}; सीटीआर सी; c.inc(); c.inc(); c.inc(); अदालत
1 1
2 2
3 3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) inc called 3 times; n=3.
व्याख्या (हिन्दी) inc को 3 बार कॉल किया गया; एन=3.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में Data Structures and Algorithms ("Introduction to DSA" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 453

EN + हिं
GB The output of: class Box{double l,w,h; public: Box(double a,double b,double c):l(a),w(b),h(c){} double vol(){return l*w*h;} }; Box b(3,4); cout<
IN का आउटपुट: क्लास बॉक्स {डबल एल, डब्ल्यू, एच; सार्वजनिक: बॉक्स (डबल ए, डबल बी, डबल सी): एल (ए), डब्ल्यू (बी), एच (सी) {} डबल वॉल्यूम() {रिटर्न एल * डब्ल्यू * एच; } }; बॉक्स बी(3,4); अदालत
9 9
24 24
14 14
6 6
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2*3*4=24.
व्याख्या (हिन्दी) 2*3*4=24.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो Data Structures and Algorithms ("Introduction to DSA" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 454

EN + हिं
GB The output of: class Vec{int x,y; public: Vec(int a,int b):x(a),y(b){} Vec operator+(Vec v){return Vec(x+v.x,y+v.y);} void print(){cout<
IN का आउटपुट: वर्ग Vec{int x,y; सार्वजनिक: Vec(int a,int b):x(a),y(b){} Vec ऑपरेटर+(Vec v){रिटर्न Vec(x+v.x,y+v.y);} void print(){cout
4,6 4,6
1,2 1,2
3,4 3,4
2,4 2,4
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (1+3, 2+4)=(6).
व्याख्या (हिन्दी) (1+3, 2+4)=(6).
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 455

EN + हिं
GB The output of: class A{public:int x; A(int x):x(x){}}; class B:public A{public:B(int x):A(x){}}; B b(42); cout<
IN का आउटपुट: क्लास ए {सार्वजनिक: int x; A(int x):x(x){}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:बी(int x):ए(x){}}; बी बी(42); अदालत
42 42
Error गलती
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B passes 42 to A constructor; b.x=42.
व्याख्या (हिन्दी) बी, ए कंस्ट्रक्टर को 42 पास करता है; बी.एक्स=42.
🎯 Exam Perspective
यह सवाल Data Structures and Algorithms ("Introduction to DSA" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 456

EN + हिं
GB The output of: class A{public:virtual int f(){return 1;}}; class B:public A{public:int f()override{return 2;}}; class C:public B{public:int f()override{return 3;}}; A*p=new C; cout<f();
IN इसका आउटपुट: क्लास ए{पब्लिक:वर्चुअल इंट एफ(){रिटर्न 1;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f()ओवरराइड{वापसी 2;}}; कक्षा सी:सार्वजनिक बी{सार्वजनिक:int f()ओवरराइड{वापसी 3;}}; ए*पी=नया सी; अदालत
1 1
2 2
3 3
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Dynamic dispatch: p points to C; C::f() returns 3.
व्याख्या (हिन्दी) गतिशील प्रेषण: पी सी को इंगित करता है; C::f() रिटर्न 3.
🎯 Exam Perspective
यह प्रश्न Data Structures and Algorithms ("Introduction to DSA" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 457

EN + हिं
GB The output of: class A{public:int f(){return 1;} virtual int g(){return 10;}}; class B:public A{public:int f(){return 2;} int g()override{return 20;}}; A*p=new B; cout<f()<g();
IN इसका आउटपुट: क्लास ए {पब्लिक: इंट एफ() {रिटर्न 1;} वर्चुअल इंट जी() {रिटर्न 10;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f(){रिटर्न 2;} int g()ओवरराइड{रिटर्न 20;}}; ए*पी=नया बी; अदालत
12 12
1 20 1 20
2 10 2 10
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->f(): non-virtual, calls A::f()=1; p->g(): virtual, calls B::g()=20.
व्याख्या (हिन्दी) p->f(): गैर-आभासी, कॉल A::f()=1; p->g(): आभासी, कॉल B::g()=20।
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 458

EN + हिं
GB The output of: template T min3(T a,T b,T c){return a
IN इसका आउटपुट: टेम्पलेट T min3(T a,T b,T c){return a
1 1
2 2
3 3
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min(1,2)=1.
व्याख्या (हिन्दी) मिनट(1,2)=1.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में Data Structures and Algorithms ("Introduction to DSA" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 459

EN + हिं
GB The output of: vector v={5,2,8,1,9}; auto comp=[](int a,int b){return a>b;}; sort(v.begin(),v.end(),comp); cout<
IN का आउटपुट: वेक्टर v={5,2,8,1,9}; ऑटो COMP=[](int a,int b){return a>b;}; क्रमबद्ध करें (v.begin(),v.end(),comp); अदालत
1 1
5 5
9 9
2 2
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Descending sort; v[0]=9.
व्याख्या (हिन्दी) अवरोही प्रकार; वी[0]=9.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो Data Structures and Algorithms ("Introduction to DSA" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 460

EN + हिं
GB The output of: map m={{1,"one"},{2,"two"},{3,"three"}}; for(auto &[k,v]:m) cout<
IN इसका आउटपुट: मानचित्र m={{1,"एक"},{2,"दो"},{3,"तीन"}}; for(auto &[k,v]:m) कॉउट
ott ओ.टी
oto ओटो
ooo ओह
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) one->o, two->t, three->t; outputs ott.
व्याख्या (हिन्दी) एक->ओ, दो->टी, तीन->टी; आउटपुट ओ.टी.
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 461

EN + हिं
GB The output of: auto v=vector{3,1,4,1,5,9,2,6}; ranges::sort(v); cout<
IN का आउटपुट: ऑटो v=वेक्टर{3,1,4,1,5,9,2,6}; श्रेणियाँ::सॉर्ट(v); अदालत
19 19
18 18
91 91
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: {1,1,2,3,4,5,6,9}; v[0]=1, v[7]=9.
व्याख्या (हिन्दी) क्रमबद्ध: {1,1,2,3,4,5,6,9}; v[0]=1, v[7]=9.
🎯 Exam Perspective
यह सवाल Data Structures and Algorithms ("Introduction to DSA" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 462

EN + हिं
GB The output of: auto r=views::iota(1)|views::take(5); for(auto x:r)cout<
IN का आउटपुट: ऑटो r=views::iota(1)|views::take(5); for(auto x:r)cout
12345 12345
01234 01234
5 5
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) iota from 1 taking 5: 1,2,3,4,5.
व्याख्या (हिन्दी) 1 से आईओटीए 5 लेते हुए: 1,2,3,4,5।
🎯 Exam Perspective
यह प्रश्न Data Structures and Algorithms ("Introduction to DSA" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 463

EN + हिं
GB The output of: int n=100; auto isprime=[](int n){for(int i=2;i*i<=n;i++) if(n%i==0)return false; return n>1;}; auto primes=views::iota(2)|views::filter(isprime)|views::take(5); cout<
IN इसका आउटपुट: int n=100; ऑटो प्राइम=[](int n){for(int i=2;i*i1;}; ऑटो प्राइम्स=व्यूज::आईओटा(2)|व्यूज::फिल्टर(आईएसप्राइम)|व्यूज::टेक(5); कॉउट
5 5
10 10
4 4
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) First 5 primes: 2,3,5,7,11; distance=5.
व्याख्या (हिन्दी) प्रथम 5 अभाज्य संख्याएँ: 2,3,5,7,11; दूरी=5.
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 464

EN + हिं
GB The output of: expected e=42; cout<
IN का आउटपुट: अपेक्षित e=42; अदालत
Error गलती
42 42
string डोरी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) expected holds int 42; value() returns 42.
व्याख्या (हिन्दी) अपेक्षित होल्ड int 42; वैल्यू() 42 लौटाता है।
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में Data Structures and Algorithms ("Introduction to DSA" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 465

EN + हिं
GB The output of: expected e=unexpected("error"); cout<
IN का आउटपुट: अपेक्षित ई=अप्रत्याशित('त्रुटि'); अदालत
1 1
Error गलती
string डोरी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) unexpected sets error state; has_value()=false=0.
व्याख्या (हिन्दी) अप्रत्याशित सेट त्रुटि स्थिति; has_value()=गलत=0.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो Data Structures and Algorithms ("Introduction to DSA" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।