- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Program to find remainder without using modulo or % operator in C++

In this problem, we are given two numbers, N and D. Our task is to create a *Program to find remainder without using modulo or % operator in C++*.

**Problem description** − We need to find the remainder that will be left after dividing the number N by D. But we cannot use the modulo or % operator for this.

**Let’s take an example to understand the problem**

## Input

N = 53 D = 3

## Output

2

## Solution Approach

To find the remainder, a simple approach is to find the number less than N which is the multiple of D. And the substrate the number from N. To return the remainder.

**Program to illustrate the working of our solution**

## Example

#include <iostream> using namespace std; int findRem(int N, int D) { int i ; for(i = 0; ;i++) { if(D * i >= N) break; } return N - (D * (i-1)); } int main(){ int N = 45, D = 6 ; cout<<"The remainder after dividing "<<N<<" by "<<D<<" is"<<findRem(N, D); return 0; }

## Output

The remainder after dividing 45 by 6 is 3

Another solution is by using the integer value of the quotient of the dividing which can be extracted directly by initializing it to an int value in C++. Then multiplying it with D. And subtracting the value from N gives the remainder.

**Program to illustrate the working our solution**

## Example

#include <iostream> using namespace std; int findRem(int N, int D) { int Q = N/D; int R = N - (D * Q); return R; } int main(){ int N = 45, D = 6 ; cout<<"The remainder after dividing "<<N<<" by "<<D<<" is"<<findRem(N, D); return 0; }

## Output

The remainder after dividing 45 by 6 is 3

- Related Questions & Answers
- Modulo / Remainder in Arduino
- C Program to find sum of two numbers without using any operator
- JavaScript: How to check if a number is even without using the modulo operator?
- C++ Program to Find Quotient and Remainder
- Division without using ‘/’ operator in C++ Program
- remainder() in C++ program
- Maximum of four numbers without using conditional or bitwise operator in C++
- Find largest element from array without using conditional operator in C++
- Find XOR of two number without using XOR operator in C++
- What is modulo % operator in Python?
- How do I add two numbers without using ++ or + or any other arithmetic operator in C/C++?
- Program to find Quotient and Remainder in Java
- Program to find the Largest Number using Ternary Operator in C++
- Return the element-wise remainder of division with modulo operation in Numpy
- C Program to Compute Quotient and Remainder?