- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- 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 Articles
- Division without using ‘/’ operator in C++ Program
- Modulo / Remainder in Arduino
- JavaScript: How to check if a number is even without using the modulo operator?
- C Program to find sum of two numbers without using any operator
- 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++
- How do I add two numbers without using ++ or + or any other arithmetic operator in C/C++?
- What is modulo % operator in Python?
- C++ Program to Find Quotient and Remainder
- Program to find the Largest Number using Ternary Operator in C++
- Finding sum of first and last digit using divide and modulo operator in C language
- C++ Program to Print “Even” or “Odd” without using conditional statement
- C Program to print “Even” or “Odd” without using Conditional statement
- Multiples of 3 and 5 without using % operator in C++