What will be the output of the following code: cout << (5 != 2); in C++?
A. 5
B. 2
C. 1
D. Compiler error
Answer: Option C
Solution (By Examveda Team)
The output of the codecout << (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. Join The Discussion
Comments (1)
Related Questions on Variables and Data Types in C plus plus
Which of the following is a valid variable name in C++?
A. myVariable
B. 123variable
C. variable&
D. float
What is the data type of the variable 'x' in the following declaration: double x = 3.14;?
A. int
B. double
C. float
D. char

answer is wrong