Home>Article>Backend Development> What is the remainder symbol in C language?
The remainder symbol in C language is [%], and the remainder symbol depends on the dividend, that is, if the dividend is a positive number, the remainder is a positive number; if the dividend is a negative number, the remainder is a negative number, and the syntax is [dividend% divisor] =remainder].
In C language, the remainder operation is also called the modulo operation. The sign of the remainder depends on the dividend, that is, if the dividend is a positive number, the remainder is positive. number; if the dividend is a negative number, the remainder will be a negative number.
Remainder operation syntax
Remainder operator:%
被除数%除数=余数
Remainder operation example:
#includeint main(void) { printf("%d\n", 8%5); printf("%d\n", 8%-5); printf("%d\n", -8%5); printf(" %d\n", -8%-5); return 0; }
The above program output:
3 3 -3 -3
Related learning recommendations:C video tutorial
The above is the detailed content of What is the remainder symbol in C language?. For more information, please follow other related articles on the PHP Chinese website!