Examveda

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 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.

Join The Discussion

Comments (1)

  1. SUSANTA SWAIN
    SUSANTA SWAIN:
    2 years ago

    answer is wrong

Related Questions on Variables and Data Types in C plus plus