1.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void Values(int n1, int n2 = 10)
{
    using namespace std;
    cout << "1st value: " << n1;
    cout << "2nd value: " << n2;
}
int main()
{
    Values(1);
    Values(3, 4);
    return 0;
}

4.
What is the use of Namespace?

6.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
namespace first
{
    int var = 5;
}
namespace second
{
    double var = 3.1416;
}
int main ()
{
    int a;
    a = first::var + second::var;
    cout << a;
    return 0;
}

7.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
    int age = 0;
    try 
    {
        if (age < 0) 
        {
            throw "Positive Number Required";
        }
        cout << age;
    }
    catch(const char *Message)
    {
        cout << "Error: " << Message;
    }
    return 0;
}

9.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
 {
    char* buff;
    try 
    {
         buff = new char[1024];
         if (buff == 0)
           throw "Memory allocation failure!";
        else
           cout << sizeof(buff) << "Byte successfully allocated!"<<endl;
     }
    catch(char *strg)
    {
        cout<<"Exception raised: "<<strg<<endl;
     }
     return 0;
}

10.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int gcd (int a, int b)
{
    int temp;
    while (b != 0) 
    {
        temp = a % b;
        a = b;
        b = temp;
    }
    return(a);
}
int main ()
{
    int x = 15, y = 25;
    cout << gcd(x, y);
    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.