My Report

C++ Programming Practice 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

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

 
    #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
    {
        int array[] = {10, 20, 30};
        cout << -2[array];
        return 0;
    }

2. Which of the following is illegal?

3. What is the use of dynamic_cast operator?

4. The constants are also called as _____________

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

6. Which operator is having the highest precedence?

7. What will happen when the structure is declared?

8. Which one of the following is not a possible state for a pointer.

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

    #include <stdio.h>
    #include<iostream>
    using namespace std;
    int main()
    {
        int a = 5, b = 10, c = 15;
        int arr[3] = {&a, &b, &c};
        cout << *arr[*arr[1] - 8];
        return 0;
    }

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

    #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
    {
        char str[5] = "ABC";
        cout << str[3];
        cout << str;
        return 0;
    }

 

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.