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
616
EN + हिं
GB The output of: char s[]="Hello World"; char* p=strtok(s," "); cout<
IN का आउटपुट: char s[]='हैलो वर्ल्ड'; char* p=strtok(s," "); अदालत
A
Hello World हैलो वर्ल्ड
B
Hello नमस्ते
C
World दुनिया
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) strtok splits on space; first token = "Hello".
व्याख्या (हिन्दी) स्ट्रोक अंतरिक्ष पर विभाजित होता है; पहला टोकन = "हैलो"।
617
EN + हिं Medium
GB memcpy vs memmove difference:
IN मेमसीपीवाई बनाम मेममूव अंतर:
A
Same function वही कार्य
B
memmove handles overlapping source/dest; memcpy does not मेमूव ओवरलैपिंग स्रोत/गंतव्य को संभालता है; memcpy नहीं करता है
C
memcpy is safer memcpy अधिक सुरक्षित है
D
memmove is undefined मेममूव अपरिभाषित है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) memmove is safe for overlapping regions.
व्याख्या (हिन्दी) ओवरलैपिंग क्षेत्रों के लिए मेमोव सुरक्षित है।
618
EN + हिं
GB The output of: int arr[5]={1,2,3,4,5}; memset(arr,0,sizeof(arr)); cout<
IN इसका आउटपुट: int arr[5]={1,2,3,4,5}; मेमसेट(arr,0,sizeof(arr)); अदालत
A
3 3
C
Error गलती
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) memset fills all bytes with 0.
व्याख्या (हिन्दी) मेमसेट सभी बाइट्स को 0 से भरता है।
619
EN + हिं
GB The output of: int a=1,b=2; memcpy(&a,&b,sizeof(int)); cout<
IN का आउटपुट: int a=1,b=2; memcpy(&a,&b,sizeof(int)); अदालत
A
1 1
B
2 2
C
Error गलती
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) memcpy copies b into a; a becomes 2.
व्याख्या (हिन्दी) memcpy b को a में कॉपी करता है; ए 2 हो जाता है.
620
EN + हिं
GB What is the output: printf("%d %d %d",1,2,3);
IN आउटपुट क्या है: printf("%d %d %d",1,2,3);
A
1 2 3 1 2 3
B
123 123
C
1,2,3 1,2,3
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) printf with %d for each int.
व्याख्या (हिन्दी) प्रत्येक इंट के लिए %d के साथ प्रिंटफ।
621
EN + हिं
GB What is the output: scanf("%d",&n) with input 42; printf("%d",n);
IN आउटपुट क्या है: scanf("%d",&n) इनपुट 42 के साथ; प्रिंटफ ("%d",n);
A
42 42
B
Error गलती
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) scanf reads 42; printf outputs 42.
व्याख्या (हिन्दी) स्कैनफ़ 42 पढ़ता है; प्रिंटफ आउटपुट 42.
622
EN + हिं Easy
GB What does perror("msg") do in C++?
IN पेरर ("msg") C++ में क्या करता है?
A
Print msg only केवल संदेश प्रिंट करें
B
Print msg + colon + system error message for errno त्रुटि के लिए संदेश + कोलन + सिस्टम त्रुटि संदेश प्रिंट करें
C
Set errno ग़लती से सेट करें
D
Clear error त्रुटि साफ़ करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) perror outputs description of last system error.
व्याख्या (हिन्दी) पेरर अंतिम सिस्टम त्रुटि का विवरण आउटपुट करता है।
623
EN + हिं
GB The output of: FILE* f=tmpfile(); fprintf(f,"test"); rewind(f); char buf[10]; fscanf(f,"%s",buf); cout<
IN इसका आउटपुट: FILE* f=tmpfile(); fprintf(f,"परीक्षण"); रिवाइंड(एफ); चार बफ़[10]; fscanf(f,"%s",buf); अदालत
A
test परीक्षा
B
Error गलती
C
empty खाली
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Write test to temp file, rewind, read back test.
व्याख्या (हिन्दी) अस्थायी फ़ाइल में परीक्षण लिखें, रिवाइंड करें, वापस परीक्षण पढ़ें।
624
EN + हिं
GB What is the output: jmp_buf jb; if(!setjmp(jb)){cout<<"A"; longjmp(jb,1);} cout<<"B";
IN आउटपुट क्या है: jmp_buf jb; if(!setjmp(jb)){cout
A
AB अब
B
A
C
B बी
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) setjmp saves point; prints A; longjmp jumps back; now setjmp returns 1 (truthy); else: print B.
व्याख्या (हिन्दी) setjmp बिंदु बचाता है; ए प्रिंट करता है; लॉन्गजम्प वापस कूदता है; अब setjmp रिटर्न 1 (सत्य); अन्य: बी प्रिंट करें।
625
EN + हिं Medium
GB longjmp in C++ is:
IN C++ में longjmp है:
A
Safer than exception अपवाद से अधिक सुरक्षित
B
Dangerous - does not call destructors (use C++ exceptions instead) खतरनाक - विध्वंसकों को कॉल नहीं करता (इसके बजाय C++ अपवादों का उपयोग करें)
C
Same as throw फेंकने के समान
D
Same as return वापसी के समान
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) longjmp skips destructors; use throw/catch in C++.
व्याख्या (हिन्दी) longjmp विध्वंसकों को छोड़ देता है; C++ में थ्रो/कैच का उपयोग करें।
626
EN + हिं
GB The output of: int x=5; auto l=coroutine_not_shown; cout<
IN का आउटपुट: int x=5; ऑटो l=coroutine_not_show; अदालत
A
Error गलती
B
5 5
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Without coroutine context, normal code prints 5.
व्याख्या (हिन्दी) कॉरआउटिन संदर्भ के बिना, सामान्य कोड प्रिंट होता है 5।
627
EN + हिं Medium
GB Which C++20 concept checks if type T has operator<< for ostream?
IN कौन सा C++20 कॉन्सेप्ट यह जाँचता है कि टाइप T में ऑपरेटर है या नहीं
A
std::printable एसटीडी::मुद्रण योग्य
B
Must define custom concept or use std::formattable कस्टम अवधारणा को परिभाषित करना चाहिए या std::formattable का उपयोग करना चाहिए
C
std::streamable std::स्ट्रीमयोग्य
D
std::insertable std::डालने योग्य
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) No standard concept for streamable; use requires or custom concept.
व्याख्या (हिन्दी) स्ट्रीम करने योग्य के लिए कोई मानक अवधारणा नहीं; उपयोग की आवश्यकता या कस्टम अवधारणा।
628
EN + हिं
GB The output of: for(int i=2;i<=20;i+=2) cout<
IN का आउटपुट: for(int i=2;i
A
10 10
B
11 11
C
9 9
D
20 20
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Even numbers 2,4,...,20: 10 numbers.
व्याख्या (हिन्दी) सम संख्याएँ 2,4,...,20: 10 संख्याएँ।
629
EN + हिं
GB The output of: int n=1000; for(;n>1;n/=10) cout<
IN इसका आउटपुट: int n=1000; for(;n>1;n/=10) cout
A
0 0 1 0 0 1
B
001 001
C
001 001
D
1 0 0 1 1 0 0 1
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) n=1000: 0; n=100: 0; n=10: 0; n=1: print 1. Outputs 001.
व्याख्या (हिन्दी) n=1000: 0; n=100: 0; n=10: 0; n=1: प्रिंट 1. आउटपुट 001.
630
EN + हिं
GB What is the output: int arr[]={10,20,30}; for(int &x:arr) x*=2; cout<
IN आउटपुट क्या है: int arr[]={10,20,30}; for(int &x:arr) x*=2; अदालत
A
20 20
B
40 40
C
30 30
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Range-based for with reference doubles each; arr[1]=20*2=40.
व्याख्या (हिन्दी) संदर्भ के साथ रेंज-आधारित प्रत्येक को दोगुना कर देता है; गिरफ्तार[1]=20*2=40.
616–630 of 1018