Vidyalelo
C++ Programming · all questions

Operators and Expressions in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

36

Questions

2/2

Page

Pick an option on a question to see the right answer and solution.

What will be the value of 'x' after executing the following code: int x = 5; x += 3; in C++?

Select an option to see the answer and solution.

What is the purpose of the ternary operator (?:) in C++?

Select an option to see the answer and solution.

What will be the output of the following code: cout << (4 > 3 ? "Yes" : "No"); in C++?

Select an option to see the answer and solution.

What is the result of the expression: 10 % 3 in C++?

Select an option to see the answer and solution.

What does the 'sizeof' operator return in C++?

Select an option to see the answer and solution.

What is the output of the following code: cout << (5 != 5); in C++?

Select an option to see the answer and solution.

Which operator is having the highest precedence?

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.

What is this operator called ?:?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the use of dynamic_cast operator?

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.