My Report

C++ Programming Mock Test 7


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. How many different ways are there to access an element of array classes at the ith position?

Question 1 of 10

Question 2 of 10

2. What are the design requirements for building a container from the sratch?

Question 2 of 10

Question 3 of 10

3. What is the syntax of declaraing a forward_list?

Question 3 of 10

Question 4 of 10

4. What must be an operand of operator delete?

Question 4 of 10

Question 5 of 10

5. In which type of storage location are the vector members stored?

Question 5 of 10

Question 6 of 10

6. Which of the following function is used to get the actual number of elements stored in vector?

Question 6 of 10

Question 7 of 10

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

#include <iostream>
#include <array>

using namespace std;

int main(int argc, char const *argv[])
{
	int arr1[5] = {1,2,3,4,5};
	int arr2[5] = {6,7,8,9,10};
	arr1.swap(arr2);
	for(int i=0;i<5;i++)
		cout<<arr1[i]<<" ";
	cout<<endl;
	for(int i=0;i<5;i++)
		cout<<arr2[i]<<" ";
	cout<<endl;
	return 0;
}

Question 7 of 10

Question 8 of 10

8. What is a pair?

Question 8 of 10

Question 9 of 10

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

    #include <iostream>
    #include <vector>
    using namespace std;
    int main ()
    {
        vector<int> first;
        first.assign (7,100);
        vector<int>::iterator it;
        it=first.begin()+1;
        int myints[] = {1776,7,4};
        cout << int (first.size()) << '\n';
        return 0;
    }

Question 9 of 10

Question 10 of 10

10. What will be the capacity of vector at the end in the following C++ code?

#include <iostream> 
#include <vector> 
  
using namespace std; 
  
int main() 
{ 
    vector<int> v; 
    for (int i = 1; i <= 5; i++) 
        v.push_back(i);
    v.reserve(50);
    cout<<v.capacity();
    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.