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 used to create a stream that performs both input and output operations?

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 myfunction (int x, int y) 
    {
        return x + 2 * y;
    }
    struct myclass 
    {
        int operator()(int x, int y) 
        {
            return x + 3 * y;
        }
    } myobject;
    int main () 
    {
        int init = 100;
        int numbers[] = {10, 20, 30};
        cout << accumulate (numbers, numbers + 3, init, minus<int>() );
        cout << endl;
        return 0;
    }

Question 2 of 10

Question 3 of 10

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

  
    #include <iostream>
    #include <iomanip>
    using namespace std;
    void showDate(int m, int d, int y)
    {
        cout << setfill('0');
        cout << setw(2) << m << '/'
        << setw(2) << d << '/'
        << setw(4) << y << endl;
    }
    int main()
    {
        showDate(1, 1, 2013);
        return 0;
    }

Question 3 of 10

Question 4 of 10

4. Which function is used to position back from the end of file object?

Question 4 of 10

Question 5 of 10

5. What will the monetary facet will do?

Question 5 of 10

Question 6 of 10

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

  
    #include <iostream>
    using namespace std;
    int main()
    {
        unsigned long x = 64;
        cout << x << oct << x << endl;
        return 0;
    }

Question 6 of 10

Question 7 of 10

7. Which of the following is not used as a file opening mode?

Question 7 of 10

Question 8 of 10

8. How many parameters are available in the function setbuf?

Question 8 of 10

Question 9 of 10

9. What is the signature of math in function using command line arguments?

Question 9 of 10

Question 10 of 10

10. How does the strings are stored in the memory?

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.