OOP Using C++ — MCQ Practice

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

📚 131 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
131 questions
91
EN + हिं
GB What is the output: template T clamp2(T v,T lo,T hi){return max(lo,min(v,hi));} cout<
IN आउटपुट क्या है: टेम्पलेट टी क्लैंप2(टी वी,टी लो,टी हाय){रिटर्न मैक्स(लो,मिन(वी,हाय));} कॉउट
A
100 100
B
15 0 15 0
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) clamp2(15,1,10)=10; clamp2(-5,0,5)=0. Output: 100.
व्याख्या (हिन्दी) क्लैंप2(15,1,10)=10; क्लैंप2(-5,0,5)=0. आउटपुट: 100.
92
EN + हिं
GB What is the output: template void printN(){cout<1) printN();} printN<5>();
IN आउटपुट क्या है: टेम्पलेट void printN(){cout
A
5 4 3 2 1 5 4 3 2 1
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
1 2 3 4 5 1 2 3 4 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Prints 5,4,3,2,1. Output: 5 4 3 2 1.
व्याख्या (हिन्दी) 5,4,3,2,1 प्रिंट करता है। आउटपुट: 5 4 3 2 1.
93
EN + हिं
GB What is the output: template auto makeRange(T start,T end,T step){vectorv;for(T i=start;i
IN आउटपुट क्या है: टेम्पलेट ऑटो मेकरेंज (टी स्टार्ट, टी एंड, टी स्टेप) {वेक्टरव; फॉर (टी आई = स्टार्ट; आई)
A
49 49
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
4 9 4 9
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0,3,6,9: 4 elements. back=9. Output: 49.
व्याख्या (हिन्दी) 0,3,6,9: 4 तत्व। वापस=9. आउटपुट: 49.
94
EN + हिं
GB What is the output: template bool isPalindrome(vectorv){return equal(v.begin(),v.begin()+v.size()/2,v.rbegin());} cout<({1,2,3,2,1})<({1,2,3});
IN आउटपुट क्या है: टेम्पलेट बूल isPalindrome(vectorv){returnqual(v.begin(),v.begin()+v.size()/2,v.rbegin());} cout
A
10 10
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) First is palindrome=1; second not=0. Output: 10.
व्याख्या (हिन्दी) पहला है पैलिन्ड्रोम=1; दूसरा नहीं=0. आउटपुट: 10.
95
EN + हिं
GB What is the output: template T fromBinary(string s){T n=0;for(char c:s) n=n*2+(c-'0');return n;} cout<("1010");
IN आउटपुट क्या है: टेम्प्लेट T fromBinary(string s){T n=0;for(char c:s) n=n*2+(c-'0');return n;} cout
A
10 10
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1010 binary=10. Output: 10.
व्याख्या (हिन्दी) 1010 बाइनरी=10. आउटपुट: 10.
96
EN + हिं
GB What is the output: template class Bimap{mapfwd;mapbwd; public:void insert(K k,V v){fwd[k]=v;bwd[v]=k;} V get(K k){return fwd[k];} K rget(V v){return bwd[v];}}; Bimapm; m.insert(1,"one"); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास Bimap{mapfwd;mapbwd; सार्वजनिक: शून्य सम्मिलित करें (के के, वी वी) {एफडब्ल्यूडी [के] = वी; बीडब्ल्यूडी [वी] = के;} वी प्राप्त करें (के के) {रिटर्न एफडब्ल्यूडी [के];} के आरगेट (वी वी) {रिटर्न बीडब्ल्यूडी [वी];}}; बिमापम; m.insert(1,'एक'); अदालत
A
one1 one1
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
1one 1एक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) get(1)=one; rget(one)=1. Output: one1.
व्याख्या (हिन्दी) प्राप्त करें(1)=एक; rget(एक)=1. आउटपुट: one1.
97
EN + हिं
GB What is the output: template struct NTuple{arrayd; NTuple(initializer_listil){copy(il.begin(),il.begin()+N,d.begin());} T& get(size_t i){return d[i];}}; NTuple<3,int>t={1,2,3}; cout<
IN आउटपुट क्या है: टेम्पलेट struct Ntuple{arrayd; NTuple(initializer_listil){copy(il.begin(),il.begin()+N,d.begin());} T& get(size_t i){return d[i];}}; NTuplet={1,2,3}; अदालत
A
4 4
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+3=4. Output: 4.
व्याख्या (हिन्दी) 1+3=4. आउटपुट: 4.
98
EN + हिं
GB What is the output: template T sum(T* arr,int n){T s=T{};for(int i=0;i
IN आउटपुट क्या है: टेम्पलेट T sum(T* arr,int n){T s=T{};for(int i=0;i
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
99
EN + हिं
GB What is the output: template bool contains(vectorv,T x){return find(v.begin(),v.end(),x)!=v.end();} cout<({1,2,3,4,5},3)<({1,2,3},9);
IN आउटपुट क्या है: टेम्प्लेट बूल में शामिल है (वेक्टरv,T x) {रिटर्न फाइंड (v.begin(),v.end(),x)!=v.end();} कॉउट
A
10 10
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3 found=1; 9 not found=0. Output: 10.
व्याख्या (हिन्दी) 3 पाया=1; 9 नहीं मिला=0. आउटपुट: 10.
100
EN + हिं
GB What is the output: template T median(vectorv){sort(v.begin(),v.end());return v[v.size()/2];} cout<({5,3,8,1,4});
IN आउटपुट क्या है: टेम्पलेट T माध्यिका(वेक्टरv){sort(v.begin(),v.end());रिटर्न v[v.size()/2];} कोउट
A
4 4
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,3,4,5,8. Middle=4. Output: 4.
व्याख्या (हिन्दी) क्रमबद्ध: 1,3,4,5,8. मध्य=4. आउटपुट: 4.
101
EN + हिं
GB What is the output: template struct Arr{T d[N]; int size(){return N;} T& operator[](int i){return d[i];}}; Arra{}; a[0]=1;a[1]=2;a[2]=3; cout<
IN आउटपुट क्या है: टेम्पलेट संरचना Arr{T d[N]; int आकार(){रिटर्न N;} T& ऑपरेटर[](int i){रिटर्न d[i];}}; आरा{}; a[0]=1;a[1]=2;a[2]=3; अदालत
A
4 4
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+3=4. Output: 4.
व्याख्या (हिन्दी) 1+3=4. आउटपुट: 4.
102
EN + हिं
GB What is the output: template T gcd2(T a,T b){return b==T{}?a:gcd2(b,a%b);} cout<
IN आउटपुट क्या है: टेम्पलेट T gcd2(T a,T b){return b==T{}?a:gcd2(b,a%b);} cout
A
12 12
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(24,36)=12. Output: 12.
व्याख्या (हिन्दी) जीसीडी(24,36)=12. आउटपुट: 12.
103
EN + हिं
GB What is the output: template string join(string sep,Args... args){ostringstream oss;bool first=true;((oss<<(first?first=false,string{}:sep)<
IN आउटपुट क्या है: टेम्प्लेट स्ट्रिंग जॉइन(स्ट्रिंग sep,Args...args){ostringstream oss;boolfirst=true;((oss
A
1-2-3 1-2-3
B
123 123
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Join with '-': 1-2-3. Output: 1-2-3.
व्याख्या (हिन्दी) '-' से जुड़ें: 1-2-3. आउटपुट: 1-2-3.
104
EN + हिं
GB What is the output: template constexpr int fib=N<2?N:fib+fib; cout<;
IN आउटपुट क्या है: टेम्पलेट constexpr int fib=N
A
55 55
B
34 34
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fib(10)=55. Output: 55.
व्याख्या (हिन्दी) फ़िब(10)=55. आउटपुट: 55.
105
EN + हिं
GB What is the output: template auto makeVector(int n,T val)->vector{return vector(n,val);} auto v=makeVector(5,3); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो मेकवेक्टर(इंट एन,टी वैल)->वेक्टर{रिटर्न वेक्टर(एन,वैल);} ऑटो वी=मेकवेक्टर(5,3); अदालत
A
53 53
B
35 35
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size=5, val=3. Output: 53.
व्याख्या (हिन्दी) आकार=5, वैल=3. आउटपुट: 53.
91–105 of 131