Test Series - cpp

Test Number 37/102

Q: How to unlimit the size of the stack?
A. setrlimit()
B. unlimit()
C. both setrlimit() & unlimit()
D. setflimit()
Solution: setrlimit() is used to unlimit the size of the stack.
Q: In Linux, how do the heaps and stacks are managed?
A. ram
B. secondary memory
C. virtual memory
D. static memory
Solution: In virtual memory, We can keep track of all the objects and access them much faster than any another.
Q: Which is used to pass the large objects in c++?
A. pass by value
B. pass by reference
C. both pass by value & reference
D. pass by name
Solution: Because by using pass by reference we need to pass only address location, So it can save a lot of memory.
Q: What are the essential operators in c++?
A. +
B. |
C. <=
D. All of the mentioned
Solution: Essential operators in c++ are +, |, <=.
Q: In which direction does the assignment operation will take place?
A. left to right
B. right to left
C. top to bottom
D. bottom to top
Solution: In assignment operation, the flow of execution will be from right to left only.
Q: Pick out the compound assignment statement.
A. a = a – 5
B. a = a / b
C. a -= 5
D. a = a + 5
Solution: When we want to modify the value of a variable by performing an operation on the value currently stored, We will use compound assignment statement. In this option, a -=5 is equal to a = a-5.
Q: What is the associativity of add(+);?
A. right to left
B. left to right
C. right to left & left to right
D. top to bottom
Solution: left to right is the associativity of add(+);.
Q: What is the name of | operator?
A. sizeof
B. or
C. and
D. modulus
Solution: | operator is used to find the β€˜or’ of given values.
Q: Which operator is having the highest precedence in c++?
A. array subscript
B. Scope resolution operator
C. static_cast
D. dynamic_cast
Solution: Scope resolution operator is having the highest precedence in c++.
Q: What will be the output of the following C++ code?

    #include 
    using namespace std;
    int main()
    {
        int a = 20;
        int b = 10;
        int c = 15;
        int d = 5;
        int e;
        e = a + b * c / d;
        cout << e << endl ;
        return 0;
    }
A. 50
B. 60
C. 70
D. 90
Solution: In this program, the value e is evaluated by precedence ad we got the output as 50.
Output:
$ g++ ess4.cpp
$ a.out
50

You Have Score    /10