Which operator is used to compare two values for equality in C?
a) ==
b) =
c) !=
d) >>
Answer:
a) ==
Explanation:
In C, the ==
operator is used to compare two values for equality. It returns true
if the values are equal and false
otherwise. This operator is commonly used in conditional statements, such as if
and while
, to control the flow of the program based on comparisons.
Understanding how to use the ==
operator correctly is fundamental for making comparisons and decisions in your C programs.