Relational operators are used to compare values to each other. The chart below contains the different types of relational operators you can use in C:
If you are comparing two values, and the statement turns out to be false, the computer will return 0. Likewise, if the statement turns out to be true, the computer will return 1. Refer to the examples below:
int num = (10 == 3); // in this case, num would save the value of 0 // because the statement is false → 10 is not equal to 3.
int num = (10 > 3); // in this case, num would save the value of 1 // because the statement is true → 10 is greater than 3.
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact email@example.com for inquiries.