Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the division of two integers in C language?
What is the division of two integers in C language?
In C language, the result of dividing two integers is divided into two situations:

If both integers are integers, the result of their division is also integers, and the result will be rounded to 0, that is, the value after the decimal point will be discarded.

For example: int a = 7, b = 3, c; c = a/b; The value of c is 2.

If at least one of two integers is floating-point, the result of their division is also floating-point, and the result retains the value after the decimal point.

For example: float a = 7.0, b = 3.0, c; c = a/b; The value of c is 2.3333333.

It should be noted that if the divisor is 0, it will cause errors or exceptions in C language and need special treatment.

You can learn this by programming at a higher level in your C language environment. Good luck with your C language study!