Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. What is the output of following C++ code?
#include
using namespace std;
void square (int *x, int *y)
{
*x = (*x) * --(*y);
}
int main ( )
{
int number = 30;
square(&number, &number);
cout << number;
return 0;
}
Correct Answer is : It will eat up a lot of memory and program size
2. From which function the execution of a C++ program starts?
Correct Answer is : All of the mentioned
3. Which of the following is important in a function?
Correct Answer is : right to left
4. What are functors in C++?
Correct Answer is : a -= 5
5. Which of the following operators are overloaded for functors?
Correct Answer is : a:4 b:7
6. What is the correct function prototype of () operator overloading?
Correct Answer is : 7
7. Which of the following is correct about Functors?
Correct Answer is : FALSE
8. What is the output of the following?
#include
using namespace std;
class Print
{
public:
void operator()(int a){
cout<
9. What is the output of the following C++ code?
#include
using namespace std;
class Add
{
int x;
public:
Add(int x){
this->x = x;
}
int operator()(int a){
return x+a;
}
};
int main()
{
Add add_5(5);
int a = 5;
cout<
Correct Answer is : or
10. Given the below class, what is the correct syntax of declaring a functor that adds 10 to each of the passed argument?
class Add
{
int x;
public:
Add(int x){
this->x = x;
}
int operator()(int a){
return x+a;
}
};
12. Which of te following is a built-in example of functors in C++?
Correct Answer is : A problem that arises during the execution of a program
13. Which of the following header file is required to use in-bulit functors of C++?
Correct Answer is : Results in the termination of the program
14. What are unary functors?
Correct Answer is : To avoid unexpected behaviour of a program during run-time
15. What are binary functors?
Correct Answer is : Using try-catch block
16. Which of the following is a logical unary functor?
Correct Answer is : finally part
17. Which of the following is an arithmetic unary functor?
Correct Answer is : Divide by zero
18. What of the following is the equivalent statement for the functor call,
x = f(arg1, arg2);
where f is a functor and arg1 and arg2 are the arguments required by the functors?
Correct Answer is : Violation of syntactic and semantic rules of a languages
19. Which header file is used to operate on numeric sequences?
Correct Answer is : Exceptions can be handled at the run-time but the errors cannot
20. Which mathematics library is used for vector manipulation in c++?