Program to find remainder without using modulo or % operator | C ++ implementation of the approach ; Function to return num % divisor without using % ( modulo ) operator ; While divisor is smaller than n , keep subtracting it from num ; Driver code
#include <iostream> NEW_LINE using namespace std ; int getRemainder ( int num , int divisor ) { while ( num >= divisor ) num -= divisor ; return num ; } int main ( ) { int num = 100 , divisor = 7 ; cout << getRemainder ( num , divisor ) ; return 0 ; }