My Report

C++ Programming Mock Test 10


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 of the following is a logical unary functor?

Question 1 of 10

Question 2 of 10

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

    #include <iostream>
    #include <functional>
    #include <numeric> 
    using namespace std;
    int myaccumulator (int x, int y) 
    {
        return x - y;
    }
    int myproduct (int x, int y) 
    {
        return x + y;
    }
    int main () 
    {
        int a = 100;
        int series1[] = {10, 20, 30};
        int series2[] = {1, 2, 3};
        cout << inner_product(series1, series1 + 3, series2, a ,myaccumulator, 
        myproduct);
        cout << endl;
        return 0;
    }

Question 2 of 10

Question 3 of 10

3. Which function is used to optimize the space in vector?

Question 3 of 10

Question 4 of 10

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

  
    #include <cstdlib>
    #include <iostream>
    using namespace std;
    int main()
    {
        cout << RAND_MAX << endl;
    }

Question 4 of 10

Question 5 of 10

5. What is the main feature of locale in C++?

Question 5 of 10

Question 6 of 10

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

    #include <iostream>
    #include <limits>
    using namespace std;
    int main( )
    {
        cout << numeric_limits<float> :: min_exponent << endl;
    }

Question 6 of 10

Question 7 of 10

7. What type of reference should be used in vector arithmetic?

Question 7 of 10

Question 8 of 10

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

#include<iostream>
using namespace std;
int main()
{
	int a = 5;
	int b = 5;
	auto check = [&a]() 
        {
		a = 10;
		b = 10;
	}
	check();
	cout<<"Value of a: "<<a<<endl;
	cout<<"Value of b: "<<b<<endl;
	return 0;
}

Question 8 of 10

Question 9 of 10

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

    #include <stdio.h>
    #include <stdlib.h>
    int main ()
    {
        div_t divresult;
        
        divresult = div (38, 5);
        printf ("%d\n", divresult.rem);
        return 0;
    }

Question 9 of 10

Question 10 of 10

10. How are many number of characters available in newname.txt?

    #include <stdio.h>
    int main ()
    {
        FILE * p;
        int n = 0;
        p = fopen ("newname.txt", "rb");
        if (p == NULL) 
            perror ("Error opening file");
        else
        {
            while (fgetc(p) != EOF)
            {
                ++n;
            }
            if (feof(p)) 
            {
                printf ("%d\n", n);
            }
            else
                puts ("End-of-File was not reached.");
            fclose (p);
        }
        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.