Class 7 Exam  >  Class 7 Tests  >  Test: C++ Operators - Class 7 MCQ

Test: C++ Operators - Class 7 MCQ


Test Description

10 Questions MCQ Test - Test: C++ Operators

Test: C++ Operators for Class 7 2024 is part of Class 7 preparation. The Test: C++ Operators questions and answers have been prepared according to the Class 7 exam syllabus.The Test: C++ Operators MCQs are made for Class 7 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: C++ Operators below.
Solutions of Test: C++ Operators questions in English are available as part of our course for Class 7 & Test: C++ Operators solutions in Hindi for Class 7 course. Download more important topics, notes, lectures and mock test series for Class 7 Exam by signing up for free. Attempt Test: C++ Operators | 10 questions in 10 minutes | Mock test for Class 7 preparation | Free important questions MCQ to study for Class 7 Exam | Download free PDF with solutions
Test: C++ Operators - Question 1

Which operator is having the highest precedence?

Detailed Solution for Test: C++ Operators - Question 1

The operator which is having the highest precedence is postfix and lowest is equality.

Test: C++ Operators - Question 2

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

    #include <iostream>
    using namespace std;
    int main()
    {
        int a;
        a = 5 + 3 * 5;
        cout << a;
        return 0;
    }

Detailed Solution for Test: C++ Operators - Question 2

Because the * operator is having highest precedence, So it is executed first and then the + operator will be executed.
Output:
$ g++ op1.cpp
$ a.out
20

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: C++ Operators - Question 3

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

    #include <iostream>
    using namespace std;
    int main()
    {
        int a = 5, b = 6, c, d;
        c = a, b;
        d = (a, b);
        cout << c << ' ' << d;
        return 0;
    }

Detailed Solution for Test: C++ Operators - Question 3

It is a separator here. In C, the value a is stored in c and in d the value b is stored in d because of the bracket.
Output:
$ g++ op3.cpp
$ a.out
5    6

Test: C++ Operators - Question 4

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

    #include <iostream>
    using namespace std;
    int main ()
    {
        int x, y;
        x = 5;
        y = ++x * ++x;
        cout << x << y;
        x = 5;
        y = x++ * ++x;
        cout << x << y;
        return 0;
    }

Detailed Solution for Test: C++ Operators - Question 4

Because of the precedence the pre-increment and post increment operator, we got the output as 749736.
Output:
$ g++ op.cpp
$ a.out
749735

Test: C++ Operators - Question 5

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

    #include <iostream>
    using namespace std;
    main()
    {
        double a = 21.09399;
        float b = 10.20;
        int c ,d;
        c = (int) a;
        d = (int) b;
        cout << c <<' '<< d;
        return 0;
    }

Detailed Solution for Test: C++ Operators - Question 5

In this program, we are casting the operator to integer, So it is printing as 21 and 10.
Output:
$ g++ op5.cpp
$ a.out
21    10

Test: C++ Operators - Question 6

Which operator is having the right to left associativity in the following?

Detailed Solution for Test: C++ Operators - Question 6

There are many rights to left associativity operators in C++, which means they are evaluation is done from right to left. Type Cast is one of them. Here is a link of the associativity of operators: https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/cpp/cpp-built-in-operators-precedence-and-associativity.md

Test: C++ Operators - Question 7

What is this operator called ?:?

Detailed Solution for Test: C++ Operators - Question 7

In this operator, if the condition is true means, it will return the first operator, otherwise second operator.

Test: C++ Operators - Question 8

What is the use of dynamic_cast operator?

Detailed Solution for Test: C++ Operators - Question 8

Because the dynamic_cast operator is used to convert from base class to derived class.

Test: C++ Operators - Question 9

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

    #include <iostream>
    using namespace std;
    int main()
    {
        int i, j;
        j = 10;
        i = (j++, j + 100, 999 + j);
        cout << i;
        return 0;
    }

Detailed Solution for Test: C++ Operators - Question 9

j starts with the value 10. j is then incremented to 11. Next, j is added to 100. Finally, j (still containing 11) is added to 999 which yields the result 1010.
Output:
$ g++ op2.cpp
$ a.out
1010

Test: C++ Operators - Question 10

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

    #include <iostream>
    using namespace std;
    int main()
    {
        int a = 5, b = 6, c;
        c = (a > b) ? a : b;
        cout << c;
        return 0;
    }

Detailed Solution for Test: C++ Operators - Question 10

Here the condition is false on conditional operator, so the b value is assigned to c.
Output:
$ g++ op1.cpp
$ a.out
6

Information about Test: C++ Operators Page
In this test you can find the Exam questions for Test: C++ Operators solved & explained in the simplest way possible. Besides giving Questions and answers for Test: C++ Operators, EduRev gives you an ample number of Online tests for practice

Top Courses for Class 7

Download as PDF

Top Courses for Class 7