- 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

We are given the total number of elements and the task is to calculate the total number of matrices with different orders that can be formed with the given data. A matrix has an order mxn where m are the number of rows and n are the number of columns.

**Input** − int numbers = 6

**Output** −Count of matrices of different orders that can be formed with the given number of elements are: 4

**Explanation** − we are given with the total number of elements that a matrix of any order can contain which is 6. So the possible matrix order with 6 elements are (1, 6), (2, 3), (3, 2) and (6, 1) which are 4 in number.

**Input** − int numbers = 40

**Output** − Count of matrices of different orders that can be formed with the given number of elements are: 8

**Explanation** − we are given with the total number of elements that a matrix of any order can contain which is 40. So the possible matrix order with 40 elements are (1, 40), (2, 20), (4, 10), (5, 8), (8, 5), (10, 4), (20, 2) and (40, 1) which are 8 in number.

Input the total number of elements that can be used to form the different order of matrices.

Pass the data to the function for further calculation

Take a temporary variable count to store the count of matrices of with different order

Start loop FOR from i to 1 till the number

Inside the loop, check IF number % i = 0 then increment the count by 1

Return the count

Print the result

#include <iostream> using namespace std; //function to count matrices (of different orders) with given number of elements int total_matrices(int number){ int count = 0; for (int i = 1; i <= number; i++){ if (number % i == 0){ count++; } } return count; } int main(){ int number = 6; cout<<"Count of matrices of different orders that can be formed with the given number of elements are: "<<total_matrices(number); return 0; }

If we run the above code it will generate the following output −

Count of matrices of different orders that can be formed with the given number of elements are: 4

- Related Questions & Answers
- Count subarrays with equal number of occurrences of two given elements in C++
- Count occurrences of the average of array elements with a given number in C++
- Count number of smallest elements in given range in C++
- Count number of elements between two given elements in array in C++
- Queries on number of Binary sub-matrices of Given size in C++
- Count number of triplets with product equal to given number in C++
- Number of indexes with equal elements in given range in C++
- Count number of elements in an array with MongoDB?
- Count number of subsets of a set with GCD equal to a given number in C++
- Possible number of Rectangle and Squares with the given set of elements in C++
- Count of quadruplets with given Sum in C++
- Count number of triplets with product equal to given number with duplicates allowed in C++
- Count number of right triangles possible with a given perimeter in C++
- Count of number of given string in 2D character array in C++
- Count the number of common divisors of the given strings in C++

Advertisements