My Report

C++ Programming Mock 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
 10%

Question 1 of 10

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

    #include <iostream>
    using namespace std;
    int func(int m = 10, int n)
    {
        int c;
        c = m + n;
        return c;
    }
    int main()
    {
        cout << func(5);
        return 0;
    } 

Question 1 of 10

Question 2 of 10

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

    #include <iostream>
    using namespace std;
    int add(int first, int second)
    {
        return first + second + 15;
    }
    int operation(int first, int second, int (*functocall)(int, int))
    {
        return (*functocall)(first, second);
    }
    int main()
    {
        int  a;
        int  (*plus)(int, int) = add;
        a = operation(15, 10, plus);
        cout << a;
        return 0;
    }

Question 2 of 10

Question 3 of 10

3. 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);
    } 

Question 3 of 10

Question 4 of 10

4. What does the data type defined by union will do?

Question 4 of 10

Question 5 of 10

5. 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;
    }

Question 5 of 10

Question 6 of 10

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

    #include <iostream>
    using namespace std;
    #define MAX 10
    int main()
    {
        int num;
        num = ++MAX;
        cout << num;
        return 0;
    }

Question 6 of 10

Question 7 of 10

7. Pick the correct statement.

Question 7 of 10

Question 8 of 10

8. Overloaded functions are ________________

Question 8 of 10

Question 9 of 10

9. What is the maximum number of arguments or parameters that can be present in one function call?

Question 9 of 10

Question 10 of 10

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

    #include <iostream>
    using namespace std;
    void square (int *x)
    {
	*x = (*x + 1) * (*x);
    }
    int main ( )
    {
	int num = 10;
        square(&num);
        cout << num; 
        return 0;
    }

Question 10 of 10


 

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.