Home >Backend Development >C#.Net Tutorial >How to express the integer division symbol in C language?

How to express the integer division symbol in C language?

烟雨青岚
烟雨青岚Original
2020-06-23 09:57:1126748browse

How to express the integer division symbol in C language?

#How to represent the integer division symbol in C language?

In C language, integer division is the / symbol, and the % symbol is the remainder operator.

"/" is an arithmetic operator in C language, used for various numerical operations; arithmetic operators include addition (), subtraction (-), multiplication (*), and division (/) , remainder (or modular operation, %), self-increment ( ), self-decrement (--), a total of seven types.

What you need to note about the integer division operator (/) is that the operation result will be automatically converted to the same data type as the dividend.

An example is as follows:

int a=5, b=2;
float c;
c = a/b;

The operation result is 2.0, not 2.5. Because a is of int type, the calculation result will be converted to int type, and c is of float type. So finally convert the integer type 2 to float type.

Recommended tutorial: "C Language"

The above is the detailed content of How to express the integer division symbol 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