Home >Backend Development >C#.Net Tutorial >What is the remainder operator in C language?

What is the remainder operator in C language?

烟雨青岚
烟雨青岚Original
2020-07-03 09:16:3228469browse

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.

What is the remainder operator in C language?

% 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:

What is the remainder operator in C language?

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:

What is the remainder operator in C language?

Example

What is the remainder operator in C language?

When the above When the code is compiled and executed, it will produce the following results:

What is the remainder operator in C language?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn