- 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

# C++ code to find total elements in a matrix

Suppose, we are given a matrix of n rows and m columns. We have to find out the number of elements present in it. We find out the value and display it as output.

So, if the input is like n = 20, m = 15, then the output will be 300.

## Steps

To solve this, we will follow these steps −

return n * m

## Example

Let us see the following implementation to get better understanding −

#include <bits/stdc++.h> using namespace std; #define N 100 int solve(int n, int m) { return n * m; } int main() { int n = 20, m = 15; cout<< solve(n, m); return 0; }

## Input

20, 15

## Output

300

- Related Questions & Answers
- C++ code to find out the sum of the special matrix elements
- C++ code to find total number of digits in special numbers
- C++ code to find total time to pull the box by rabbit
- C++ code to find out the total amount of sales we made
- How to find the sum of rows, columns, and total in a matrix in R?
- Program to find minimum total cost for equalizing list elements in Python
- Find distinct elements common to all rows of a matrix in Python
- Find distinct elements common to all rows of a Matrix in C++
- How to find the row total of columns having same name in R matrix?
- How to find the mean of a square matrix elements by excluding diagonal elements in R?
- How to find the variance of row elements of a matrix in R?
- Python – Sort Matrix by total characters
- How to find the sum of anti-diagonal elements in a matrix in R?
- HTML Computer Code Elements
- How to find the sum of all elements of a given matrix using Numpy?

Advertisements