ExamVeda
Login
Home
21
What will be the value of 'x' after executing the following code: int x = 5; x += 3; in C++?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
22
What is the purpose of the ternary operator (?:) in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
23
What will be the output of the following code: cout << (4 > 3 ? "Yes" : "No"); in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
24
What is the result of the expression: 10 % 3 in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
25
What does the 'sizeof' operator return in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
26
What is the output of the following code: cout << (5 != 5); in C++?
Discuss
Answer & Solution
Answer: Option D
Solution:
This question asks us to find the output of a simple C++ code snippet.
The `cout` part is used to print something to the screen in C++.
Inside `cout`, we have the expression `(5 != 5)`. Let's break this down.
The `!=` is an "inequality operator". It means "not equal to".
This operator checks if the value on its left side is NOT equal to the value on its right side.
So, `5 != 5` is asking: "Is 5 not equal to 5?"
Let's evaluate this statement: Is 5 actually different from 5? No, 5 is exactly equal to 5.
Therefore, the statement `5 != 5` is false.
In C++, when you print a boolean value (true or false) directly using `cout` without any special formatting, it typically prints a numerical equivalent:
- `true` is usually printed as `1`.
- `false` is usually printed as `0`.
Since `5 != 5` evaluates to `false`, `cout` will print its numerical representation.
Thus, the final output will be 0.
The correct answer is Option D.
27
Which operator is having the highest precedence?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
28
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;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
29
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;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
30
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;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board