Vidyalelo
C++ Programming · all questions

Functions and Procedures in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

176

Questions

3/9

Page

Pick an option on a question to see the right answer and solution.

In C++, what is a lambda function?

Select an option to see the answer and solution.

What is the purpose of the 'decltype' keyword in C++?

Select an option to see the answer and solution.

What is the correct way to declare a function that takes a pointer as an argument in C++?

Select an option to see the answer and solution.

What will be the output of the following code: void display() { cout << "Hello"; } int main() { display(); return 0; } in C++?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int func (int a, int b)
{
    cout << a;
    cout << b;
    return 0;
}
int main(void)
{
    int(*ptr)(char, int);
    ptr = func;
    func(2, 3);
    ptr(2, 3);
    return 0;
}

Select an option to see the answer and solution.

If we start our function call with default arguments means, what will be proceeding arguments?

Select an option to see the answer and solution.

Which of the following is the default return value of functions in C++?

Select an option to see the answer and solution.

What is an inline function?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
 include <iostream>
using namespace std;
long factorial (long a)
{
    if (a > 1)
        return (a * factorial (a + 1));
    else
        return (1);
}
int main ()
{
   long num = 3;
   cout << num << "! = " << factorial ( num );
   return 0;
}

Select an option to see the answer and solution.

Identify the correct statement.

Select an option to see the answer and solution.

What is the scope of the variable declared in the user defined function?

Select an option to see the answer and solution.

If an argument from the parameter list of a function is defined constant then . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void Funct();
int main()
{
    try 
    {
        Funct();
    }
    catch(double) 
    {
        cerr << "caught a double type..." << endl;
    }
    return 0;
 }
void Funct()
{
    throw 3;
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Identify the correct statement.

Select an option to see the answer and solution.

which of the following can be passed in function pointers?

Select an option to see the answer and solution.

Where should default parameters appear in a function prototype?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace A{
 
	int var = 10;
}
namespace B{
	int cout = 5;
}
int main()
{
	using namespace B;
	cout<<A::var;
}

Select an option to see the answer and solution.

Which is more effective while calling the functions?

Select an option to see the answer and solution.

What is similar to the interface in c++?

Select an option to see the answer and solution.