
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Found 7197 Articles for C++

113 Views
In this problem, we are given two dimensional arrays mat[n][m]. Our task is to find the number of endless points in the matrix.Any point of the matrix is said to be endless if its next elements are 1. i.e.mat[i][j] is endless when mat[i+1][j] … mat[n][j] and mat[i][j+1] … mat[i][m] are 1.Let’s take an example to understand the problem, Inputmat[][] = {0, 0} {1, 1}Output2ExplanationElement mat[0][1] and mat[1][1] are endless.Solution ApproachA simple solution to the problem is by iterating all elements of the matrix. And for each element check if the current element is endless or not. If yes, increase count. ... Read More

6K+ Views
In this problem, we are given two arrays date1[] and date2 consisting of 3 integers which denote the DD-MM-YYYY of daes. Our task is to find the number of days between two given dates.Let’s take an example to understand the problem, Inputdate1[] = {13, 3, 2021}, date2[] = {24, 5, 2023}Output802ExplanationThe difference is 2 years , 2 months (3 - 5) and 11 days.2*356 + (30 + 31) + 11 = 802Solution ApproachA simple solution to the problem is by looping, starting from the start date date1 to date2 counting the number of days. And returning the value. This approach ... Read More

239 Views
In this problem, we are given an array divisors[] consisting of N integers which are the divisors of a number Num. Our task is to find the number from its divisors.The divisor array does not include 1 and the number.Let’s take an example to understand the problem, Inputdivisors[] = {3, 25, 5, 15}Output75ExplanationThe number 75 has divisors {3, 25, 5, 15}Solution ApproachTo solve the problem, we need to find the number Num using the smallest and largest divisors of the number.Num = smallest * largestFor this, we need to sort the array divisors[] and then find the product of elements ... Read More

215 Views
In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 5, 13, 25, 41, 61, …Let’s take an example to understand the problem,InputN = 5Output61ExplanationThe series is − 5, 13, 25, 41, 61…Solution ApproachA simple approach to solve the problem is by using the general formula for the nth term of the series. The Nth term is given by,Nth term = ( (N*N) + ((N+1)*(N+1)) )Program to illustrate the working of our solution,Example Live Demo#include using namespace std; int calcNthTerm(int N) { return ( ( (N + 1)*( N + 1) ) + (N*N) ) ; } int main() { int N = 7; cout

210 Views
In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 5, 2, 19, 13, 41, 31, 71, 57…Let’s take an example to understand the problem, InputN = 5Output41ExplanationThe series is − 5, 2, 19, 13, 41, …Solution ApproachA simple approach to solve the problem is by using the general formula for the nth term of the series. The series has different formulas for even and odd values.The Nth term is given by, Nth term = (N-1)^2 + N, if N is even i.e N%2 == 0 Nth term ... Read More

172 Views
In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 3, 14, 39, 84…Let’s take an example to understand the problem,InputN = 4Output84Explanation4th term − ( (4*4*4) + (4*4) + 4 ) = 64 + 16 + 4 = 84Solution ApproachA simple approach to solve the problem is by using the general formula for the nth term of the series. The formula for,Nth term = ( (N*N*N) + (N*N) + (N))Program to illustrate the working of our solution,Example Live Demo#include using namespace std; int calcNthTerm(int N) { return ( (N*N*N) + (N*N) + (N) ); } int main() { int N = 6; cout

164 Views
In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 1,8, 54, 384 ...Let’s take an example to understand the problem,InputN = 4Output384Explanation4th term − (4 * 4 * (4!) = 384Solution ApproachA simple approach to solve the problem is by using the general formula for the nth term of the series. The formula for,Nth term = ( N * N * (N !) )Program to illustrate the working of our solution,Example Live Demo#include using namespace std; int calcFact(int N) { int fact = 1; for (int i = 1; i

259 Views
In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 1,6, 18, 40, 75 ...Let’s take an example to understand the problem,InputN = 4Output40Explanation4th term − (4 * 4 * 5 ) / 2 = 40Solution ApproachA simple approach to solve the problem is by using the general formula for the nth term of the series. The formula for,Nth term = ( N * N * (N + 1) ) / 2Program to illustrate the working of our solution,Example Live Demo#include using namespace std; int calcNthTerm(int N) { return ( (N*N*(N+1))/2 ); } int main() { int N = 5; cout

346 Views
In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 1,5, 32, 288 ...Let’s take an example to understand the problem,InputN = 4Output288Explanation4th term − (4^4) + (3^3) + (2^2) + (1^1) = 256 + 27 + 4 + 1 = 288Solution ApproachA simple approach to solve the problem is by using the general formula for the nth term of the series. The formula for,Nth term = ( N^N ) + ( (N-1)^(N-1) ) + … + ( 2^2 ) + ( 1^1 )Program to illustrate the working of our solution,Example Live Demo#include using namespace std; int calcNthTerm(int N) { if (N

531 Views
In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 1,1, 2, 6, 24, ...Let’s take an example to understand the problem,InputN = 7Output720ExplanationThe series is − 1, 1, 2, 6, 24, 120, 720Solution ApproachA simple approach to solve the problem is by using the general formula for the nth term of the series. The formula for,Nth term = (N−1)!Program to illustrate the working of our solution,Example Live Demo#include using namespace std; int calcNthTerm(int N) { if (N