My Report

C++ Programming Mock Test 2


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. Which operator is having the right to left associativity in the following?

Question 1 of 10

Question 2 of 10

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

  
    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int array1[] = {1200, 200, 2300, 1230, 1543};
    int array2[] = {12, 14, 16, 18, 20};
    int temp, result = 0;
    int main()
    {
        for (temp = 0; temp < 5; temp++) 
        {
            result += array1[temp];
        }
        for (temp = 0; temp < 4; temp++)
        {
            result += array2[temp];
        }
        cout << result;
        return 0;
    } 

Question 2 of 10

Question 3 of 10

3. Pick the correct statement about references in C++.

Question 3 of 10

Question 4 of 10

4. The switch statement is also called as?

Question 4 of 10

Question 5 of 10

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

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

Question 5 of 10

Question 6 of 10

6. What will happen when the structure is declared?

Question 6 of 10

Question 7 of 10

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

    #include <iostream>
    using namespace std;
    enum test 
    {
        A = 32, B, C
    };
    int main()
    {
        cout << A << B<< C;
        return 0;
    } 

Question 7 of 10

Question 8 of 10

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

    #include <iostream>
    using namespace std;
    void addprint()
    {
        static int s = 1;
        s++;
        cout << s;
    }
    int main()
    {
        addprint();
        addprint();
        addprint();
        return 0;
    } 

Question 8 of 10

Question 9 of 10

9. Identify the incorrect option.

Question 9 of 10

Question 10 of 10

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

#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int a = 5;
	int *p = &a;
	int &q = a;
	cout<<p<<endl;
	cout<<q<<endl;
	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.