ExamVeda
Login
Home
31
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
string askNumber(string prompt = "Please enter a number: ");
int main()
{
    string number = askNumber();
    cout << "Here is your number: " << number;
    return 0;
}
string askNumber(string prompt)
{
    string number;
    cout << prompt;
    cin << number;
    return number;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
32
What are mandatory parts in the function declaration?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
33
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int add(int a, int b);
int main()
{
    int i = 5, j = 6;
    cout << add(i, j) << endl;
    return 0;
}
int add(int a, int b )
    {
        int sum = a + b;
        a = 7;
        return a + b;
    }
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
34
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int max(int a, int b )
{
    return ( a > b ? a : b );
}
int main()
{
    int i = 5;
    int j = 7;
    cout << max(i, j );
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
35
How many types of modularization are there in c++?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
36
By default how the value are passed in c++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
37
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void PrintSequence(int StopNum)
{
    int Num;
    Num = 1;
    while (true) 
    {
        if (Num >= StopNum)
            throw Num;
        cout << Num;
        Num++;
    }
}
int main(void)
{
    try 
    {
        PrintSequence(20);
    }
    catch(int ExNum)
    {
        cout << "Caught an exception with value: " << ExNum;
    }
    return 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
38
What will we not do with function pointers?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
39
Which header file is used to pass unknown number of arguments to function?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
40
What will be the new value of x in the following C++ code?
#include <iostream>
using namespace std;
void fun(int &x)
{
    x = 20;
}
int main()
{
     int x = 10;
     fun(x);
     cout << "New value of x is " << x;
     return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board