c / beginner
Snippet
Arithmetic Operators and Modulo
C supports standard arithmetic like addition and subtraction. The modulo operator (%) is unique as it returns the remainder of an integer division (e.g., 11 divided by 3 is 3 with a remainder of 2).
snippet.c
c
1
2
int total = 10 + 5;int remainder = 11 % 3;
Breakdown
1
int total = 10 + 5;
Performs basic addition of two integers.
2
int remainder = 11 % 3;
Calculates the remainder of 11 divided by 3, which results in 2.