Home > Article > Backend Development > What is the remainder operator in C language?
The remainder operator in C language is "%". The remainder operator is also called the modulo division operator. It is used to find the remainder. Both operands are required to be integers. If the operand to the left of "%" is a negative number, the result of the modulo division will be a negative number or 0; if "%" "When the operand on the left is a positive number, the modular division structure is a positive number or 0.
% is the remainder operator, also called the modular division operator, used to find the remainder.
%Requires both operands to be integers (or types that can be implicitly converted to integers).
Standard regulations:
If the operand to the left of % is a negative number, the result of modulo division is a negative number or 0,
If the operand to the left of % is a positive number When , the modular division structure is a positive number or 0.
Sample code:
c is a character type, and its 235 corresponds to the binary bit 0xFD, which is the complement form of -3. Then c is converted to int and is -3;
Extended information
The following table shows all arithmetic operators supported by C language. Assume that the value of variable A is 10 and the value of variable B is 20, then:
Example
When the above When the code is compiled and executed, it will produce the following results:
Recommended tutorial: "C Language"
The above is the detailed content of What is the remainder operator in C language?. For more information, please follow other related articles on the PHP Chinese website!