Operators
In addition to having operators that perform basic mathematical operations like addition, subtraction, multiplication, and division, C also has operators that perform other functions: like finding the remainder when dividing, or updating the value of a variable. C’s arithmetic operators perform mathematical functions on numbers. The + operator adds two numbers, the - operator subtracts one number from another, the * operator multiplies two numbers, and the / symbol divides one number by another. C also provides assignment operators, which provide a variety of ways to update the value of a variable.
-
Lecture
-
Short
-
Notes
-
Supplementary Resources
- Tutorials Point on C operators
- Programiz on C Programming
-
Thought Questions
- How do operators in C compare to operators in math? Do they always translate to the same thing?
- Why is there a difference between integer division and float division?
- Why is modulo (
%) a built in operation? - What are some problems where modulo might come in handy? What about integer division?
- What are
x++,x--,+=, and*=shorthand for?
-
Problem