C Plus Plus Miscellaneous - Study Mode
[#706] What will be the output of the following C++ code? #include <iostream>
#include <cctype>
using namespace std
int main(int argc, char const *argv[])
{
char arr[27] = "abcdefghijklmnopqrstuvwxyz"
for(int i=0
i<27
i++)
{
cout<<(bool)isxdigit(arr[i])
}
}
Correct Answer
(C) 111111000000000000000000000
[#707] What will be the output of the following C++ code? #include <iostream>
#include <vector>
using namespace std
int main()
{
vector<int> v
for (int i = 1
i <= 5
i++)
v.push_back(i)
cout<<v.size()
cout<<endl<<v.capacity()
return 0
}
Correct Answer
(B) 5 8
[#708] What will be the output of the following C++ code? #include <iostream>
using namespace std
template <class type>
class Test
{
public:
Test()
{
}
~Test()
{
}
type Funct1(type Var1)
{
return Var1
}
type Funct2(type Var2)
{
return Var2
}
}
int main()
{
Test<int> Var1
Test<double> Var2
cout << Var1.Funct1(200)
cout << Var2.Funct2(3.123)
return 0
}
Correct Answer
(D) 2003.123
[#709] What will be the output of the following C++ code? #include <iostream>
#include <iterator>
using namespace std
int main ()
{
try {
double value1, value2
istream_iterator<double> eos
istream_iterator<double> iit (cin)
if (iit != eos)
value1 = *iit
iit++
if (iit != eos)
value2 = *iit
cout << (value1 * value2) << endl
}
catch (...) {
cout << "Unknown exception: " << endl
}
return 0
}
Correct Answer
(C) It will print the multiplied value of the input
[#710] What will be the output of the following C++ code? #include <iostream>
#include <string>
#include <cstdlib>
using namespace std
template<class T>
class A
{
public:
T func(T a, T b){
return a/b
}
}
int main(int argc, char const *argv[])
{
A <int>a1
cout<<a1.func(3,2)<<endl
cout<<a1.func(3.0,2.0)<<endl
return 0
}
Correct Answer
(A) 1 1