Examveda
Examveda

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

A. ==

B. =

C. !=

D. <>

Answer: Option A

Solution(By Examveda Team)

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.

This Question Belongs to C Program >> C Fundamentals

Join The Discussion

Related Questions on C Fundamentals