Sail E0 Webinar

MCQs

Total Questions : 8
Question 1.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int gcd (int a, int b)
4.
{
5.
int temp;
6.
while (b != 0) {
7.
temp = a % b;
8.
a = b;
9.
b = temp;
10.
}
11.
return(a);
12.
}
13.
int main ()
14.
{
15.
int x = 15, y = 25;
16.
cout
  1.    15
  2.    25
  3.    375
  4.    5
 Discuss Question
Answer: Option D. -> 5

In this program, we are finding the gcd of the number.
Output:
$ g++ ret5.cpp
$ a.out
5


Question 2.

When will we use the function overloading?


  1.    same function name but different number of arguments
  2.    different function name but same number of arguments
  3.    same function name but same number of arguments
  4.    different function name but different number of arguments
 Discuss Question
Answer: Option A. -> same function name but different number of arguments

In function overloading, we can use any number of arguments but same function name.


Question 3.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int mult (int x, int y)
4.
{
5.
int result;
6.
result = 0;
7.
while (y != 0) {
8.
result = result + x;
9.
y = y - 1;
10.
}
11.
return(result);
12.
}
13.
int main ()
14.
{
15.
int x = 5, y = 5;
16.
cout
  1.    20
  2.    25
  3.    30
  4.    35
 Discuss Question
Answer: Option B. -> 25

 We are multiplying these values by adding every values.
Output:
$ g++ ret.cpp
$ a.out
25


Question 4.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
double & WeeklyHours()
4.
{
5.
double h = 46.50;
6.
double &hours = h;
7.
return hours;
8.
}
9.
int main()
10.
{
11.
double hours = WeeklyHours();
12.
cout
  1.    46.5
  2.    6.50
  3.    compile time error
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 46.5

We are returning the value what we get as input.
Output:
$ g++ ret1.cpp
$ a.out
46.5


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int max(int a, int b )
4.
{
5.
return ( a > b ? a : b );
6.
}
7.
int main()
8.
{
9.
int i = 5;
10.
int j = 7;
11.
cout
  1.    5
  2.    7
  3.    either a or b
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> 7

In this program, we are returning the maximum value by using conditional operator.
Output:
$ g++ ret.cpp
$ a.out
7


Question 6.

Where does the return statement returns the execution of the program?


  1.    main function
  2.    caller function
  3.    same function
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> caller function

None.


Question 7.

What will you use if you are not intended to get a return value?


  1.    static
  2.    const
  3.    volatile
  4.    void
 Discuss Question
Answer: Option D. -> void

Void is used to not to return anything.


Question 8.

How many types of returning values are present in c++?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option C. -> 3

The three types of returning values are return by value, return by reference and return by address.


Latest Videos

Latest Test Papers