Vidyalelo
C Programming · Q19

C Fundamentals

Programming · C Programming · question 19

Q19

Which operator is used to compare two values for equality in C?

A.
==
Answer
B.
=
C.
!=
D.
<>

Answer: Option A

Solution

Answer: Option A
Solution:
The operator used to compare two values for equality in C is Option A: ==. The double equal sign (==) is the equality operator, and it is used to check if two values are equal to each other.

So, the correct answer is:
Option A: ==
Here's an example of using the equality operator in C:
int x = 5;
int y = 10;

if (x == y) {
    // This condition will not be met because x is not equal to y
    printf("x is equal to y");
} else {
    printf("x is not equal to y"); // This will be printed
}

In this example, the program checks if 'x' is equal to 'y' using the == operator and prints the result based on the comparison.