ExamVeda
Login
Home
11
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
double & WeeklyHours()
{
    double h = 46.50;
    double &hours = h;
    return hours;
}
int main()
{
    double hours = WeeklyHours();
    cout << "Weekly Hours: " << hours;
    return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
12
How many minimum number of functions should be present in a C++ program for its execution?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
13
What is the ability to group some lines of code that can be included?
in the program?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
14
Function overloading is also similar to which of the following?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
15
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int add(int first, int second)
{
    return first + second + 15;
}
int operation(int first, int second, int (*functocall)(int, int))
{
    return (*functocall)(first, second);
}
int main()
{
    int  a;
    int  (*plus)(int, int) = add;
    a = operation(15, 10, plus);
    cout << a;
    return 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
16
What will be the output of the following C++ code?
#include <iostream>
#include <stdarg.h>
using namespace std;
void fun(std::string msg, ...);
int main()
{
    fun("cPlusPlus", 1, 4, 7, 11, 0);
    return 0;
}
void fun(std::string msg, ...)
{
    va_list ptr;
    int num;
    va_start(ptr, msg);
    num = va_arg(ptr, int);
    num = va_arg(ptr, int);
    cout << num;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
17
What changes you can do in the header files to avoid the redefinition that compiler will give when both the header files are included in the same program keeping the declaration of both the functions same?
Content of h1.h
------------------------------------------------
h1.h
#include <iostream>
using namespace std;
int func(int a){
	cout<<"Multiplied by 2";
	return 2*a;
}
------------------------------------------------
 
Content of h2.h
------------------------------------------------
h2.h
#include <iostream>
using namespace std;
int func(int a){
	cout<<"divided by 2";
	return a/2;
}
------------------------------------------------
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
18
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int n(char, int);
int (*p) (char, int) = n;
int main()
{
    (*p)('d', 9);
    p(10, 9);
    return 0;
}
int n(char c, int i)
{
    cout << c <<  i;
    return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
19
Where does the execution of the program starts?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
20
When we define the default values for a function?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board