What is the remainder symbol in C language?

coldplay.xixi
Release: 2020-08-29 11:34:57
Original
64214 people have browsed it

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].

What is the remainder symbol in C language?

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

被除数%除数=余数
Copy after login

Remainder operation example:

#include <stdio.h>
int main(void)
{
    printf("%d\n", 8%5);
    printf("%d\n", 8%-5);
    printf("%d\n", -8%5);
    printf(" %d\n", -8%-5);
    return 0;
}
Copy after login

The above program output:

3
3
-3
-3
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template