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
421
EN + हिं Medium
GB Which C++ keyword marks a variable as thread-local storage?
IN कौन सा C++ कीवर्ड एक वेरिएबल को थ्रेड-लोकल स्टोरेज के रूप में चिह्नित करता है?
A
static स्थिर
B
thread_local थ्रेड_लोकल
C
thread धागा
D
local स्थानीय
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) thread_local int x; each thread has its own x.
व्याख्या (हिन्दी) थ्रेड_लोकल int x; प्रत्येक धागे का अपना x होता है।
422
EN + हिं
GB The output of: constexpr int sq(int n){return n*n;} static_assert(sq(5)==25); cout<<"OK";
IN इसका आउटपुट: constexpr int sq(int n){return n*n;} static_assert(sq(5)==25); अदालत
A
Error गलती
B
OK ठीक है
C
25 25
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) constexpr sq is evaluated at compile time; static_assert passes.
व्याख्या (हिन्दी) संकलन समय पर constexpr sq का मूल्यांकन किया जाता है; static_assert पास हो जाता है।
423
EN + हिं Medium
GB static_assert in C++ checks:
IN C++ जाँच में static_assert:
A
Runtime assertion रनटाइम दावा
B
Compile-time assertion; program fails to compile if condition is false संकलन-समय का दावा; यदि स्थिति गलत है तो प्रोग्राम संकलित करने में विफल रहता है
C
Dynamic assertion गतिशील दावा
D
Memory assertion स्मृति दावा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) static_assert(condition, "message") is a compile-time check.
व्याख्या (हिन्दी) static_assert(condition, "message") एक संकलन-समय जाँच है।
424
EN + हिं
GB The output of: template void f(T&&x){cout<::value;} int a=5; f(a); f(5);
IN इसका आउटपुट: टेम्पलेट शून्य f(T&&x){cout
A
10 10
B
01 01
C
11 11
D
00 00
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(a): T deduced as int& (lvalue ref = 1); f(5): T deduced as int (rvalue = 0).
व्याख्या (हिन्दी) f(a): T को int& के रूप में निकाला गया (lvalue Ref = 1); f(5): T को int (rvalue = 0) के रूप में निकाला गया।
425
EN + हिं
GB What is the output: int arr[3][3]={{1,2,3},{4,5,6},{7,8,9}}; cout<
IN आउटपुट क्या है: int arr[3][3]={{1,2,3},{4,5,6},{7,8,9}}; अदालत
A
5 5
B
6 6
C
7 7
D
8 8
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) arr[1][2]: row 1 (second row), col 2 (third col) = 6.
व्याख्या (हिन्दी) एआर[1][2]: पंक्ति 1 (दूसरी पंक्ति), कॉलम 2 (तीसरा कॉलम) = 6।
426
EN + हिं
GB The output of: int** p; int a[2][2]={{1,2},{3,4}}; p=new int*[2]; for(int i=0;i<2;i++) p[i]=a[i]; cout<
IN का आउटपुट: int** p; int a[2][2]={{1,2},{3,4}}; पी=नया पूर्णांक*[2]; for(int i=0;i
A
2 2
B
3 3
C
4 4
D
1 1
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p[1][0] = a[1][0] = 3.
व्याख्या (हिन्दी) पी[1][0] = ए[1][0] = 3.
427
EN + हिं
GB The output of: char* s="Hello"; cout<
IN का आउटपुट: char* s='हैलो'; अदालत
A
5 5
B
6 6
C
4 4
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) strlen counts chars before null: H-e-l-l-o = 5.
व्याख्या (हिन्दी) स्ट्रेलेन शून्य से पहले वर्णों की गिनती करता है: एच-ई-एल-एल-ओ = 5।
428
EN + हिं
GB The output of: char a[]="Hello"; char b[]="World"; strcat(a,b); cout<
IN का आउटपुट: char a[]='हैलो'; चार बी[]='विश्व'; स्ट्रैटकैट(ए,बी); अदालत
A
Hello नमस्ते
B
World दुनिया
C
HelloWorld हैलो वर्ल्ड
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) strcat appends b to a.
व्याख्या (हिन्दी) strcat b को a से जोड़ता है।
429
EN + हिं
GB The output of: char a[]="Hello"; char b[]="Hello"; cout<
IN का आउटपुट: char a[]='हैलो'; चार बी[]='हैलो'; अदालत
A
1 1
C
-1 -1
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Identical strings; strcmp returns 0.
व्याख्या (हिन्दी) समान तार; strcmp 0 लौटाता है।
430
EN + हिं
GB The output of: char a[]="Apple"; char b[]="Banana"; cout<<(strcmp(a,b)<0?"a=b");
IN का आउटपुट: char a[]='Apple'; चार बी[]='केला'; अदालत
A
a>=b ए>=बी
B
a<b
C
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A < B alphabetically; strcmp<0.
व्याख्या (हिन्दी) ए <बी वर्णानुक्रम में; strcmp
431
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".
व्याख्या (हिन्दी) स्ट्रोक अंतरिक्ष पर विभाजित होता है; पहला टोकन = "हैलो"।
432
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.
व्याख्या (हिन्दी) ओवरलैपिंग क्षेत्रों के लिए मेमोव सुरक्षित है।
433
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 से भरता है।
434
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 हो जाता है.
435
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 के साथ प्रिंटफ।
421–435 of 819