- 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

In this tutorial, we are going to write a program that divides one array of elements by another array of elements.

Here, we are following a simple method to complete the problem. Let's see the steps to solve the problem.

Initialize the two arrays.

Iterate through the second array and find the product of the elements.

Iterate through the first array and divide each element with a product of the second array elements.

Let's see the code.

#include <bits/stdc++.h> using namespace std; void divideArrOneWithTwo(int arr_one[], int arr_two[], int n, int m) { int arr_two_elements_product = 1; for (int i = 0; i < m; i++) { if (arr_two[i] != 0) { arr_two_elements_product = arr_two_elements_product * arr_two[i]; } } for (int i = 0; i < n; i++) { cout << floor(arr_one[i] / arr_two_elements_product) << " "; } cout << endl; } int main() { int arr_one[] = {32, 22, 4, 55, 6}, arr_two[] = {1, 2, 3}; divideArrOneWithTwo(arr_one, arr_two, 5, 3); return 0; }

If you run the above code, then you will get the following result.

5 3 0 9 1

If you have any queries in the tutorial, mention them in the comment section.

- Related Questions & Answers
- Count array elements that divide the sum of all other elements in C++
- Print array elements that are divisible by at-least one other in C++
- Count elements that are divisible by at-least one element in another array in C++
- Find the element having different frequency than other array elements in C++
- Maximum number by concatenating every element in a rotation of an array in C++
- Find the element that appears once in an array where every other element appears twice in C++
- Find original array from encrypted array (An array of sums of other elements) using C++.
- Elements of an array that are not divisible by any element of another array in C++
- Program to find length of the largest subset where one element in every pair is divisible by other in Python
- Maximum possible XOR of every element in an array with another array in C++
- Python program to copy all elements of one array into another array
- C++ program to Adding elements of an array until every element becomes greater than or equal to k
- Finding sum of every nth element of array in JavaScript
- Find closest value for every element in array in C++
- Adding elements of an array until every element becomes greater than or equal to k in C++.

Advertisements