My Report

C++ Function Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following C++ code?

    #include <iostream>
    using namespace std;
    int operate (int a, int b)
    {
        return (a * b);
    }
    float operate (float a, float b)
    {
        return (a / b);
    }
    int main()
    {
        int x = 5, y = 2;
        float n = 5.0, m = 2.0;
        cout << operate(x, y) <<"\t";
        cout << operate (n, m);
        return 0;
    } 

2. What will be the output of the following C++ code?

    #include <iostream>
    using namespace std;
    int Add(int X, int Y, int Z)
    {
        return X + Y;
    }
    double Add(double X, double Y, double Z)
    {
        return X + Y;
    }
    int main()
    {
        cout << Add(5, 6);
        cout << Add(5.5, 6.6);
        return 0;
    } 

3. Function overloading is also similar to which of the following?

4. Which of the following permits function overloading on c++?

5. What are the advantages of passing arguments by reference?

6. What should be passed in parameters when function does not require any parameters?

7. Overloaded functions are ________________

8. What will be the output of the following C++ code?

    #include <iostream>
    using namespace std;
    void print(int i)
    {
        cout << i;
    }
    void print(double  f)
    {
        cout << f;
    }
    int main(void)
    {
        print(5);
        print(500.263);
        return 0;
    } 

9. What will happen while using pass by reference?

10. In which of the following we cannot overload the function?


 

Start practicing “1000 MCQs on C++”, and once you are ready, you can take tests on all topics by attempting our “C++ Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.