- 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)
300 Views
In this tutorial, we will be discussing a program to find the number of paths between two vertices.For this we will be provided with a directed graph. Our task is to find the number of paths possible between two given vertices.Example#include using namespace std; //constructing a directed graph class Graph{ int V; list *adj; void countPathsUtil(int, int, bool [], int &); public: //constructor Graph(int V); void addEdge(int u, int v); int countPaths(int s, int d); }; Graph::Graph(int V){ this->V = V; adj ... 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 the number of possible N digit numbers that satisfy the given condition.For this we will be provided with an integer. Our task is to check which one of number having N digits followNumber + Reverse(Number) = 10N -1Example#include using namespace std; //returning the count of numbers string count_num(int N){ if (N % 2 == 1) return 0; string result = "9"; for (int i = 1; i
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
180 Views
In this tutorial, we will be discussing a program to find the number of possible groups of size 2 or 3 that have sum as multiple of 3.In this tutorial, we will be discussing a program to find the number of possible groups of size 2 or 3 that have sum as multiple of 3.Example#include using namespace std; //returning count of pairs of //2 or 3 int count_groups(int arr[], int n){ int c[3] = {0}, i; int res = 0; for (i=0; i>1); res += c[1] * c[2]; res += (c[0] * (c[0]-1) * (c[0]-2))/6; ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
200 Views
In this tutorial, we will be discussing a program to find the number of all perfect divisors of a number.For this we will be provided with a number. Our task is to count all the perfect divisors of that given number.Example#include using namespace std; //checking perfect square bool if_psquare(int n){ int sq = (int) sqrt(n); return (n == sq * sq); } //returning count of perfect divisors int count_pdivisors(int n){ int count = 0; for (int i=1; i*i
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
158 Views
In this tutorial, we will be discussing a program to find the number of all palindromic subsequences in a given string.For this we will be provided with a string. Our task is to find the number of palindromic subsequences that can be made in that given string.Example#include #include using namespace std; //returning total palindromic sequence int count_palin(string str){ int N = str.length(); //creating a 2D array int cps[N+1][N+1]; memset(cps, 0 ,sizeof(cps)); for (int i=0; i
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
129 Views
In this tutorial, we will be discussing a program to find the number of palindromes which are squares of a palindrome.For this we will be provided with two values L and R. Our task is to find the number of super palindromes in the given range. A super palindrome is the one in which the number and its square both are palindromes.Example#include using namespace std; //checking if the number is a palindrome bool if_palin(int x){ int ans = 0; int temp = x; while (temp > 0){ ans = 10 * ans + ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
160 Views
In this tutorial, we will be discussing a program to find the number of palindrome sub strings in a string.For this we will be given a string. Our task is to count the number of palindrome sub strings in the given string with length greater than 3.Example#include using namespace std; //counting palindrome strings int count_pstr(char str[], int n){ int dp[n][n]; memset(dp, 0, sizeof(dp)); bool P[n][n]; memset(P, false , sizeof(P)); for (int i= 0; i< n; i++) P[i][i] = true; for (int i=0; i
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
188 Views
In this tutorial, we will be discussing a program to find the number of pairs with the given XOR.For this we will be provided with an array and a value. Our task is to find the number of pairs whose XOR is equal to the given value.Example#include using namespace std; //returning the number of pairs //having XOR equal to given value int count_pair(int arr[], int n, int x){ int result = 0; //managing with duplicate values unordered_map m; for (int i=0; i
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
115 Views
In this tutorial, we will be discussing a program to find the number of pairs of an array which differ in K bits.For this we will be provided with an array and an integer K. Our task is to find the number of pairs who differ by K bits in their binary representation.Example#include using namespace std; //counting number of bits in //binary representation int count_bit(int n){ int count = 0; while (n) { if (n & 1) ++count; n >>= 1; } return count; } ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
84 Views
In this tutorial, we will be discussing a program to find the number of pairs of adjacent nodes whose XOR is an odd number.For this we will be provided with a binary tree. Our task is to count the number of pairs of adjacent elements whose XOR is an odd number.Example Live Demo#include using namespace std; //node structure of tree struct Node { int data; struct Node *left, *right; }; //finding the pairs whose XOR //is odd int count_pair(Node* root, Node *parent=NULL){ if (root == NULL) return 0; //checking pair of XOR is ... Read More