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
631
EN + हिं
GB The output of: string words[]={"hello","world","foo"}; sort(words,words+3); cout<
IN इसका आउटपुट: स्ट्रिंग शब्द[]={"हैलो","दुनिया","फू"}; सॉर्ट करें (शब्द, शब्द+3); अदालत
A
foo फू
B
hello नमस्ते
C
world दुनिया
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Alphabetical sort: foo < hello < world.
व्याख्या (हिन्दी) वर्णमाला क्रम: फू <हैलो <दुनिया।
632
EN + हिं
GB The output of: vector v={"c","a","b"}; sort(v.begin(),v.end()); cout<
IN का आउटपुट: वेक्टर v={"c","a","b"}; क्रमबद्ध करें (v.begin(),v.end()); अदालत
A
ac ए.सी
B
ab अब
C
ca सीए
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: a,b,c; v[0]=a, v[2]=c.
व्याख्या (हिन्दी) क्रमबद्ध: ए, बी, सी; वी[0]=ए, वी[2]=सी.
633
EN + हिं
GB What is the output: auto it=max_element(begin("abcZ"),end("abcZ")-1); cout<<*it;
IN आउटपुट क्या है: auto it=max_element(begin("abcZ"),end("abcZ")-1); अदालत
A
c सी
B
Z जेड
C
a
D
b बी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ASCII: a=97,b=98,c=99,Z=90; max is c(99).
व्याख्या (हिन्दी) ASCII: a=97,b=98,c=99,Z=90; अधिकतम c(99) है।
634
EN + हिं
GB The output of: int n=7; int sum=0; for(int i=2;i<=n/2;i++) if(n%i==0){sum=1; break;} cout<<(sum?"Composite":"Prime");
IN का आउटपुट: int n=7; पूर्णांक योग=0; for(int i=2;i
A
Composite कम्पोजिट
B
Prime मुख्य
C
7 7
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 7 has no divisors in 2..3; sum stays 0; Prime.
व्याख्या (हिन्दी) 2..3 में 7 का कोई भाजक नहीं है; योग 0 रहता है; मुख्य।
635
EN + हिं
GB The output of: int n=12; int sum=0; for(int i=2;i<=n/2;i++) if(n%i==0){sum=1; break;} cout<<(sum?"Composite":"Prime");
IN का आउटपुट: int n=12; पूर्णांक योग=0; for(int i=2;i
A
Prime मुख्य
B
Composite कम्पोजिट
C
12 12
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 12/2=6; i=2: 12%2=0; sum=1; Composite.
व्याख्या (हिन्दी) 12/2=6; मैं=2: 12%2=0; योग=1; समग्र।
636
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); अदालत
A
5 5
B
7 7
C
25 25
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sqrt(9+16)=sqrt(25)=5.
व्याख्या (हिन्दी) sqrt(9+16)=sqrt(25)=5.
637
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(); अदालत
A
1 1
B
2 2
C
3 3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) inc called 3 times; n=3.
व्याख्या (हिन्दी) inc को 3 बार कॉल किया गया; एन=3.
638
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); अदालत
A
9 9
B
24 24
C
14 14
D
6 6
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2*3*4=24.
व्याख्या (हिन्दी) 2*3*4=24.
639
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
A
4,6 4,6
B
1,2 1,2
C
3,4 3,4
D
2,4 2,4
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (1+3, 2+4)=(6).
व्याख्या (हिन्दी) (1+3, 2+4)=(6).
640
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); अदालत
B
42 42
C
Error गलती
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B passes 42 to A constructor; b.x=42.
व्याख्या (हिन्दी) बी, ए कंस्ट्रक्टर को 42 पास करता है; बी.एक्स=42.
641
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;}}; ए*पी=नया सी; अदालत
A
1 1
B
2 2
C
3 3
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Dynamic dispatch: p points to C; C::f() returns 3.
व्याख्या (हिन्दी) गतिशील प्रेषण: पी सी को इंगित करता है; C::f() रिटर्न 3.
642
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;}}; ए*पी=नया बी; अदालत
A
12 12
B
1 20 1 20
C
2 10 2 10
D
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।
643
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
A
1 1
B
2 2
C
3 3
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min(1,2)=1.
व्याख्या (हिन्दी) मिनट(1,2)=1.
644
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); अदालत
A
1 1
B
5 5
C
9 9
D
2 2
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Descending sort; v[0]=9.
व्याख्या (हिन्दी) अवरोही प्रकार; वी[0]=9.
645
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) कॉउट
A
ott ओ.टी
B
oto ओटो
C
ooo ओह
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) one->o, two->t, three->t; outputs ott.
व्याख्या (हिन्दी) एक->ओ, दो->टी, तीन->टी; आउटपुट ओ.टी.
631–645 of 1018