Variables And Data Types In C Plus Plus - Study Mode
[#116] What will be the output of the following C++ code? #include <iostream>
using namespace std
enum cat
{
temp = 7
}
int main()
{
int age = 14
age /= temp
cout << "If you were cat, you would be " << age << endl
return 0
}
Correct Answer
(B) If you were cat, you would be 2
[#117] Identify the incorrect statements. int var = 10
int *ptr = &(var + 1)
//statement 1
int *ptr2 = &var //statement 2
&&var = 40
//statement 3
Correct Answer
(C) Statement 1 and 3 are wrong
[#118] What will be the output of the following C++ code? #include <iostream>
using namespace std
int main()
{
void a = 10, b = 10
int c
c = a + b
cout << c
return 0
}
Correct Answer
(B) compile time error
[#119] What will be the output of the following code: cout << (5 != 2)
in C++?
Correct Answer
(C) 1
Explanation
Solution: The output of the code cout << (5 != 2)
in C++ will be 1. The expression (5 != 2) is a comparison operation that checks if 5 is not equal to 2. Since 5 is indeed not equal to 2, the expression evaluates to true . In C++, the boolean value true is represented by 1. Therefore, the output will be 1 . However, it seems there might be a misunderstanding. The correct answer should be Option C: 1. If the options provided are fixed, then the answer should be corrected to reflect the boolean output as 1.
[#120] What is the correct way to declare a pointer to an integer in C++?
Correct Answer
(C) int *ptr