Question: 1 -
What will be the output of the following C++ code?#include <iostream>
using namespace std;
int main() {
int a, b;
a = 10;
b = 4;
a = b;
b = 7;
cout << "a: " << a;
cout << "\nb: " << b;
return 0;
}
-
a:4 b:6
-
a:4 b:10
-
a:10 b:4
-
a:4 b:7
Answer:
a:4 b:7
Solution:
In this program, we are reassigning the values of a and b because of this we got the output as a:4 b:7
In this program, we are reassigning the values of a and b because of this we got the output as a:4 b:7
Question: 2 -
Which operator is having the right to left associativity in the following?
-
Addition and subtraction
-
Array subscripting
-
Type cast
-
Function call
Answer:
Type cast
Solution not available.
Question: 3 -
In which direction does the assignment operation will take place?
-
top to bottom
-
bottom to top
-
left to right
-
right to left
Answer:
right to left
Solution:
In assignment operation, the flow of execution will be from right to left only.
In assignment operation, the flow of execution will be from right to left only.
Question: 4 -
Pick out the compound assignment statement.
-
a = a / b
-
a = a + 5
-
a = a – 5
-
a -= 5
Answer:
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.
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.
Question: 5 -
What are the essential operators in c++?
-
+
-
<=
-
|
-
All of the mentioned
Answer:
All of the mentioned
Solution:
Explanation: Essential operators in c++ are +, |, <=.
Explanation: Essential operators in c++ are +, |, <=.