Value Return Cpp MCQ

Errorlogger
0
1. How many types of returning values are present in c++?
a) 1
b) 2
c) 3
d) 4



2. What will you use if you are not intended to get a return value?
a) static
b) const
c) volatile
d) void



3. Where does the return statement returns the execution of the program?
a) main function
b) caller function
c) same function
d) none of the mentioned



4. What is the output of this program?
  1.     #include <iostream>
  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 << max(i, j );
  12.         return 0;
  13.     }
a) 5
b) 7
c) either a or b
d) none of the mentioned



5. What is the output of this program?
  1.     #include <iostream>
  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 << "Weekly Hours: " << hours;
  13.         return 0;
  14.     }
a) 46.5
b) 6.50
c) compile time error
d) none of the mentioned



6. What is the output of this program?
  1.     #include <iostream>
  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  << mult(x, y) ;
  17.         return(0);
  18.     }
a) 20
b) 25
c) 30
d) 35



7. When will we use the function overloading?
a) same function name but different number of arguments
b) different function name but same number of arguments
c) same function name but same number of arguments
d) different function name but different number of arguments



8. What is the output of this program?
  1.     #include <iostream>
  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 << gcd(x, y);
  17.         return(0);
  18.     }
a) 15
b) 25
c) 375
d) 5

Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !