- Related Questions & Answers
- C/C++ Program to Find reminder of array multiplication divided by n ?
- Python Program for Find reminder of array multiplication divided by n
- Java Program to find reminder of array multiplication divided by n
- C/C++ Program to Find the reminder of array multiplication divided by n?
- Count divisors of array multiplication in C++
- Addition multiplication ladder in an array in JavaScript\n
- C++ program for multiplication of array elements
- Find elements of an array which are divisible by N using STL in C++
- Find if array can be divided into two subarrays of equal sum in C++
- Program to find remainder when large number is divided by 11 in C++
- Program to find remainder when large number is divided by r in C++
- Can array be divided into n partitions with equal sums in JavaScript
- Find a non empty subset in an array of N integers such that sum of elements of subset is divisible by N in C++
- Matrix Chain Multiplication (A O(N^3) Solution) in C++
- Hashing by Multiplication in Data Structure

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

Suppose we have an array of n elements called A. We have to print the remainder after multiply all the numbers divided by n. Suppose A = [100, 10, 5, 25, 35, 14], and n = 11. The output is 9. So the value of 100 * 10 * 5 * 25 * 35 * 14 mod 11 = 9.

First, we have to take the remainder of each number, then multiply the remainder with the current result. After multiplication, again take the remainder to avoid overflow.

#include<iostream> #include<algorithm> using namespace std; int getRemainder(int a[], int size, int n) { int mul = 1; for(int i = 0; i<size; i++){ mul = (mul * (a[i] % n)) %n; } return mul%n; } int main() { int arr[] = {100, 10, 5, 25, 35, 14}; int size = sizeof(arr)/sizeof(arr[0]); int n = 11; cout << "The remainder is: " << getRemainder(arr, size, n); }

The remainder is: 9

Advertisements