- 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
Count all possible paths from top left to bottom right of a mXn matrix in C++
In this tutorial, we will be discussing a program to find the number of possible paths from top left to bottom right of a mXn matrix.
For this we will be provided with a mXn matrix. Our task is to find all the possible paths from top left to bottom right of the given matrix.
Example
#include <iostream> using namespace std; //returning count of possible paths int count_paths(int m, int n){ if (m == 1 || n == 1) return 1; return count_paths(m - 1, n) + count_paths(m, n - 1); } int main(){ cout << count_paths(3, 3); return 0; }
Output
6
- Related Articles
- Print all possible paths from top left to bottom right of a mXn matrix in C++
- Print all palindromic paths from top left to bottom right in a matrix in C++
- Print all paths from top left to bottom right in a matrix with four moves allowed in C++
- Maximum points from top left of matrix to bottom right and return back in C++
- Count all possible paths between two vertices in C++
- Program to count number of walls required to partition top-left and bottom-right cells in Python
- Maximum sum path in a matrix from top to bottom in C++
- Maximum sum path in a matrix from top to bottom in C++ Program
- How to display the JList items from top to bottom and left to right in Java?
- Set the left, right, top and bottom padding of an element
- A current-carrying conductor is held in exactly vertical direction. In order to produce a clockwise magnetic field around the conductor, the current should passed in the conductor:(a) from top towards bottom (b) from left towards right (c) from bottom towards top (d) from right towards left
- Maximum sum path in a matrix from top to bottom and back in C++ Program
- Program to find number of ways we can reach from top left point to bottom right point in Python
- How to add a straight line to a plot in R starting from bottom left and ending at top right?
- Print a matrix in alternate manner (left to right then right to left) in C++

Advertisements