Find Remainder C Program

By | September 14, 2016

C Program To Find Remainder of Dividend and Divisor

Let us learn how to find Remainder of a Dividend and Divisor in C programming language. Here, we have demonstrated different ways of calculating the remainder of a number.

What is a Remainder?

A remainder is an integer that is achieved after dividing two integers with each other, producing a quotient too.

The remainder will get more clear from the below-given image. When you divide 11 by 3, you multiply 3 with 3 and the remainder becomes 2 since (11 – (3*3)) = 2.

Formula To Get Remainder

Dividend = Divisor × Quotient + Remainder

Get Remainder of a Number in C Programming

Must Read: C Program To Find GCD of Two Integers

Method 1: C Program To Find Remainder of Dividend and Divisor

#include<stdio.h>

int main()
{
      int remainder, divisor, dividend;
      printf("\nEnter the Dividend:\t");
      scanf("%d", &dividend);
      printf("\nEnter the Divisor:\t");
      scanf("%d", &divisor);
      remainder = dividend % divisor;
      printf("\nRemainder of the Number:\t%d\n", remainder);
      return 0;
}

Method 2: C Program To Calculate Remainder without using Modulus Operator

#include<stdio.h>

int main()
{
      int remainder, divisor, dividend;
      printf("\nEnter the Dividend:\t");
      scanf("%d", &dividend);
      printf("\nEnter the Divisor:\t");
      scanf("%d", &divisor);
      remainder = dividend / divisor;
      remainder = remainder * divisor;
      divisor = dividend - remainder;
      printf("\nRemainder of the Number:\t%d\n", divisor);
      return 0;
}

Method 3: C Program To Get Remainder using Functions

#include<stdio.h>

int find_remainder(int a, int b)
{
      int remainder;
      remainder = a % b;
      return remainder;
}

int main()
{
      int result, divisor, dividend;
      printf("\nEnter the Dividend:\t");
      scanf("%d", &dividend);
      printf("\nEnter the Divisor:\t");
      scanf("%d", &divisor);
      result = find_remainder(dividend, divisor);
      printf("\nRemainder of the Number:\t%d\n", result);
      return 0;
}

Must Read: C Program To Find Leap Year

 

Output

C Program To Find Remainder without using Modulus Operator and Functions

In case you get any compilation errors or any doubts in this C program for calculating remainder of a number, let us know about it in the comment section below.

One thought on “Find Remainder C Program

  1. Vipul Kedia

    I was confused with Divisor and Dividend Numbers. Your image above has simplified to understand both of them. 🙂

    Reply

Let's Discuss