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.
Related Questions on C Fundamentals
What is the primary purpose of a function prototype in C?
A. Declare a variable
B. Declare a function
C. Define a function
D. Assign a value
What is the correct syntax for declaring a variable in C?
A. int variable_name;
B. variable_name = 5;
C. variable_name int;
D. int = variable_name;
Join The Discussion