22.
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
 
class Test
{
  protected:
    int x;
  public:
    Test (int i):x(i) { }
    void fun() const  { cout << "fun() const " << endl; }
    void fun()        {  cout << "fun() " << endl;     }
};
 
int main()
{
    Test t1 (10);
    const Test t2 (20);
    t1.fun();
    t2.fun();
    return 0;
}

23.
What will be the output of the following C++ code?
#include <iostream>
#include <stdarg.h>
using namespace std;
float avg( int Count, ... )
{
    va_list Numbers;
    va_start(Numbers, Count);
    int Sum = 0;
    for (int i = 0; i < Count; ++i )
        Sum += va_arg(Numbers, int);
    va_end(Numbers);
    return (Sum/Count);
}
int main()
{
    float Average = avg(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    cout << "Average of first 10 whole numbers : " << Average;
    return 0;
}

25.
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
 
int fun(int x = 0, int y = 0, int z)
{  return (x + y + z); }
 
int main()
{
   cout << fun(10);
   return 0;
}

26.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main ()
{
    cout << "Value of __LINE__ : " << __LINE__ << endl;
    cout << "Value of __FILE__ : " << __FILE__ << endl;
    cout << "Value of __DATE__ : " << __DATE__ << endl;
    cout << "Value of __TIME__ : " << __TIME__ << endl;
    return 0;
}

27.
When will we use the function overloading?

28.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void copy (int& a, int& b, int& c)
{
    a *= 2;
    b *= 2;
    c *= 2;
}
int main ()
{
    int x = 1, y = 3, z = 7;
    copy (x, y, z);
    cout << "x =" << x << ", y =" << y << ", z =" << z;
    return 0;
}

29.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void square (int *x, int *y)
{
	*x = (*x) * --(*y);
}
int main ( )
{
	int number = 30;
	square(&number, &number);
	cout << number;
	return 0;
}

Read More Section(Functions and Procedures in C plus plus)

Each Section contains maximum 100 MCQs question on Functions and Procedures in C plus plus. To get more questions visit other sections.