C Program to find remainder without using modulus operator


In this program, You will learn how to find remainder without using modulus operator in C.


0 = 10 % 5

5 = 5 % 10


Example: How to find remainder without using modulus operator in C

Run it Now
#include<stdio.h>

int main() {

   int a, b;

   printf("Enter Two Numbers :");
   scanf("%d%d", &a, &b);

   while (a >= b) {
       a = a - b;
   }

   printf("\nThe Remainder is :%d", a);

   return 0;
}

Output:

Enter Two Numbers :9 2
The Remainder is :1