Home > Article > Backend Development > How to find remainder in c language
How to find the remainder in C language?
In C language, the binary operator % is directly used to find the remainder. For example, the remainder of a divided by b can be expressed as a%b
Recommended learning: c language video Tutorial
Note: The two operands of operator % in C language must be integers and cannot be floating point or other structure types, otherwise the compiler will prompt an error.
Sample code:
#include <stdio.h> int main() { int a=5, b=3, c; c=a%b; //将a除以b的余数赋值给c printf("%d",c); return 0; } /* 输出:2 */
The above is the detailed content of How to find remainder in c language. For more information, please follow other related articles on the PHP Chinese website!