- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Found 7347 Articles for C++
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
143 Views
In this tutorial, we will be discussing a program to find maximum path sum that starting with any cell of 0-th row and ending with any cell of (N-1)-th rowFor this we will be provided with a matrix with possible moves of (i+1, j), (i+1, j-1), (i+1, j+1). Our task is to start from zeroth position and move to last row finding out the maximum sum path.Example Live Demo#include using namespace std; #define N 4 //finding maximum sum path int MaximumPath(int Mat[][N]) { int result = 0 ; int dp[N][N+2]; memset(dp, 0, sizeof(dp)); for (int i = ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
53 Views
In this tutorial, we will be discussing a program to find maximum path sum for each position with jumps under divisibility conditionFor this we will be provided with an array of n random integers. Our task is to jump from one position to another if it divides it and finally provide the maximum sum path for every given position.Example Live Demo#include using namespace std; //finding maximum sum path void printMaxSum(int arr[], int n) { int dp[n]; memset(dp, 0, sizeof dp); for (int i = 0; i < n; i++) { dp[i] = arr[i]; ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
170 Views
In this tutorial, we will be discussing a program to find maximum parent children sum in Binary treeFor this we will be provided with a binary tree. Our task is to add up the parent node with its children nodes and finally find the maximum of all of that and print it out.Example Live Demo#include using namespace std; struct Node { int data; struct Node *left, *right; }; //inserting nodes struct Node* newNode(int n) { struct Node* root = new Node(); root->data = n; root->left = root->right = NULL; return root; } int maxSum(struct ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
164 Views
In this tutorial, we will be discussing a program to find maximum of sum and product of digits until number is reduced to a single digitFor this we will be provided with a random number. Our task is to find and print out the maximum of sum and product of the digits of the given number until it coverts to a single digitExample Live Demo#include using namespace std; //converting number to single digit by adding long repeatedSum(long n) { if (n == 0) return 0; return (n % 9 == 0) ? 9 : (n % ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
89 Views
In this tutorial, we will be discussing a program to find the maximum of smallest possible area that can get with exactly k cut of given rectangular.For this we will be provided with the sides of the rectangle and the number of cuts that can be made. Our task is to calculate the smallest area that can be achieved by making the given number of cuts.Example Live Demo#include using namespace std; void max_area(int n, int m, int k) { if (k > (n + m - 2)) cout
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
439 Views
In this tutorial, we will be discussing a program to find HCF (highest common factor) of two numbers.For this we will be provided with two numbers. Our task is to find the highest common factor (HCF) of those numbers and return it.Example Live Demo#include //recursive call to find HCF int gcd(int a, int b){ if (a == 0 || b == 0) return 0; if (a == b) return a; if (a > b) return gcd(a-b, b); return gcd(a, b-a); } int main(){ int a = ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
111 Views
In this tutorial, we will be discussing a program to find greater value between a^n and b^n.For this we will be provided with three numbers. Our task is to calculate a^n and b^n and return back the greater of those values.Example Live Demo#include using namespace std; //finding the greater value void findGreater(int a, int b, int n){ if (!(n & 1)) { a = abs(a); b = abs(b); } if (a == b) cout b) cout
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
464 Views
In this tutorial, we will be discussing a program to find GCD and HCF of two numbers.For this we will be provided with two numbers. Our task is to find the GCD or HCF (highest common factor) for those given two numbers.Example Live Demo#include using namespace std; int gcd(int a, int b){ if (a == 0) return b; if (b == 0) return a; if (a == b) return a; if (a > b) return gcd(a-b, b); return gcd(a, b-a); } int main(){ int a = 98, b = 56; cout
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
1K+ Views
In this tutorial, we will be discussing a program to find GCD or HCF of two numbers using Middle School Procedure.For this we will be provided with two numbers. Our task is to find the GCD (greatest common divisor) or HCF (highest common factor) for the given values.Example Live Demo#include #define MAXFACTORS 1024 using namespace std; //structure to store factorization typedef struct{ int size; int factor[MAXFACTORS + 1]; int exponent[MAXFACTORS + 1]; } FACTORIZATION; void FindFactorization(int x, FACTORIZATION* factorization){ int i, j = 1; int n = x, c = 0; int k = ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
339 Views
In this tutorial, we will be discussing a program to find GCD of floating point numbers.For this we will be provided with two integers. Our task is to find the GCD (Greatest common divisor) of those two provided integers.Example Live Demo#include using namespace std; //returning GCD of given numbers double gcd(double a, double b){ if (a < b) return gcd(b, a); if (fabs(b) < 0.001) return a; else return (gcd(b, a - floor(a / b) * b)); } int main(){ double a = 1.20, b = 22.5; cout