Comparison: == != > < >= <= (result is 1 for true, 0 for false)
Logical: && || !
Casting
Integer division drops the decimals: 7 / 2 is 3. Cast to get a decimal result: (float) 7 / 2 is 3.5.
💡 Key Takeaways: C Operators & Type Conversion
Mastering C Operators & Type Conversion helps you write clean and reliable C code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
C Operators & Type Conversion Code Example
C
#include <stdio.h>
int main() {
int a = 7, b = 2;
printf("%d\n", a / b);
printf("%.1f\n", (float) a / b);
printf("%d\n", a % b);
printf("%d\n", a > b && b > 0);
int x = 5;
x += 3;
printf("%d\n", x++);
printf("%d\n", x);
return 0;
}
Output
3
3.5
1
1
8
9
Run this example on your own computer. The "Get Started" lesson shows how to set it up.
C Operators & Type Conversion Practice Exercises
Check what you learned in “C Operators & Type Conversion”.