How to find remainder in c language

藏色散人
Release: 2020-02-07 11:47:35
Original
46811 people have browsed it

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
*/
Copy after login

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!

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