71. Which operator is used to access the nth bit in a bitset?
72. What will be the output of the following C++ code?
#include <stdexcept>
#include <limits>
#include <iostream>
using namespace std;
void MyFunc(char c)
{
if (c < numeric_limits<char>::max())
return invalid_argument;
}
int main()
{
try
{
MyFunc(256);
}
catch(invalid_argument& e)
{
cerr << e.what() << endl;
return -1;
}
return 0;
}
#include <stdexcept>
#include <limits>
#include <iostream>
using namespace std;
void MyFunc(char c)
{
if (c < numeric_limits<char>::max())
return invalid_argument;
}
int main()
{
try
{
MyFunc(256);
}
catch(invalid_argument& e)
{
cerr << e.what() << endl;
return -1;
}
return 0;
}
73. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <class T>
class A
{
public:
A(int a): x(a) {}
protected:
int x;
};
template <class T>
class B: public A<char>
{
public:
B(): A<char>::A(100)
{
cout << x * 2 << endl;
}
};
int main()
{
B<char> test;
return 0;
}
#include <iostream>
using namespace std;
template <class T>
class A
{
public:
A(int a): x(a) {}
protected:
int x;
};
template <class T>
class B: public A<char>
{
public:
B(): A<char>::A(100)
{
cout << x * 2 << endl;
}
};
int main()
{
B<char> test;
return 0;
}
74. What is meant by sequence point?
75. Where does the member should be defined if it is used in the program?
76. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template<int n>
struct funStruct
{
static const int val = 2*funStruct<n-1>::val;
};
template<>
struct funStruct<0>
{
static const int val = 1 ;
};
int main()
{
cout << funStruct<10>::val << endl;
return 0;
}
#include <iostream>
using namespace std;
template<int n>
struct funStruct
{
static const int val = 2*funStruct<n-1>::val;
};
template<>
struct funStruct<0>
{
static const int val = 1 ;
};
int main()
{
cout << funStruct<10>::val << endl;
return 0;
}
77. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void square (int *x)
{
*x = (*x + 1) * (*x);
}
int main ( )
{
int num = 10;
square(&num);
cout << num;
return 0;
}
#include <iostream>
using namespace std;
void square (int *x)
{
*x = (*x + 1) * (*x);
}
int main ( )
{
int num = 10;
square(&num);
cout << num;
return 0;
}
78. What will be the output of the following C++ code?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
srand (time(NULL));
printf ("Random number: %d\n", rand() % 100);
srand (1);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
srand (time(NULL));
printf ("Random number: %d\n", rand() % 100);
srand (1);
return 0;
}
79. What is the use of get() function in tuples?
80. What is the difference between begin() and rbegin()?
Read More Section(C plus plus miscellaneous)
Each Section contains maximum 100 MCQs question on C plus plus miscellaneous. To get more questions visit other sections.
- C plus plus miscellaneous - Section 1
- C plus plus miscellaneous - Section 2
- C plus plus miscellaneous - Section 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 6
- C plus plus miscellaneous - Section 7
- C plus plus miscellaneous - Section 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11