In this problem, we are given a number N. Our task is to create a program to find N-th term of series 3, 12, 29, 54, 87, … in C++.The series is3, 12, 29, 54, 87, 128, .... N-TermsLet’s take an example to understand the problem, Input − N = 5Output − 87Solution Approach:Let’s deduce the general term of the given series. The series is −3, 12, 29, 54, 87, 128, ....The general term of this series isTn = 4(n2 ) - 3*n + 2Using the general term formula, we can find any value of the series.For example, T8 = ... Read More
In this problem, we are given a number N. Our task is to create a program to find N-th term of series 4, 14, 28, 46, 68, 94, 124, 158, …..in C++.Problem Description − To find the Nth term of series4, 14, 28, 46, 68, 94, 124, … (N-terms), We will find the general term of the series and calculate the value based on the value of n.Let’s take an example to understand the problem, Input − N = 5Output − 68Solution Approach:Let’s deduce the general term of the given series. The series is:4, 14, 28, 46, 68, 94, 124….We ... Read More
In this problem, we are given a number n that denotes the nth term of the series. Our task is to create a program to find the N-th term of series 7, 21, 49, 91, 147, 217, …… in C++.Problem Description - We will find the nth term of the series 7, 21, 49, 91, 147, 217, … and for that, we will deduce the general term of the series.Let’s take an example to understand the problem, Input − N = 5Output − 147Solution Approach:Let’s deduce the general term of the given series. The series is −7, 21, 49, 91, ... Read More
In this problem, we are given an integer n that denotes the nth term of the series. Our task is to create a program to find N-th term of series 9, 23, 45, 75, 113… in C++.Problem Description − Here, we need to find the nth term of the series for which we will be finding the general term of the series.The series is 9, 23, 45, 75, 113, 159, 213, …Let’s take an example to understand the problem, Input − n = 5output − 159Solution Approach, The general term of the given series isNth term = ( ((2*N + ... Read More
In this problem, we are given a quadratic equation of type ax2 + bx + c, where a, b and c are constants. Our task is to create a program to find number of solutions in Quadratic Equation in C++.Problem Description − Here, we need to find the numbers of solutions for a quadratic equation that can have at max 2 solutions.Let’s take a few examples to understand the problem, Example 1:Input − 3x2 + 7x + 4Output − 2Explanation − the two solutions of the equation are 1 and 4/3.Example 2:Input − x2 - 4x + 4Output − 1Explanation ... Read More
In this problem, we are given the size of a chessboard. Our task is to create a program to find number of squares in a chessboard in C++.Problem Description − To find the number of squares in a chessboard. We will have to calculate all the combinations of the square that are inside the chessboard i.e. we will consider squares of side 1x1, 2x2, 3x3 … nxn.Let’s take an example to understand the problem, Input: n = 4.Output: 30Squares of size 1x1 -> 16 Squares of size 2x2 -> 9 Squares of size 3x3 -> 4 Squares of size 4x4 ... Read More
In this problem, we are given input from the user. Our task is to create a program to find out the data type of user input in C++.Problem Description − We will take input from the user and check the data type of the input value.Let’s take an example to understand the problem, Example 1:Input − 34Output − It is an integerExample 2:Input − tutorialspointOutput − It is a stringSolution Approach:We will check if the input string is a number or not a number.If it is a number, we will check if it is an integer or a float value.If ... Read More
In this problem, we are given the side of a square (A) and the length and breadth of a rectangle (L and B). Our task is to create a Program to find Perimeter / Circumference of Square and Rectangle in C++.Problem Description:To find the circumference of a square, we need the side of the square (a). For that, we will use the formula for the perimeter of the square which is 4a.To find the circumference of a rectangle, we need the Length (L) and breadth (B) of the rectangle. For that, we will use the formula for the perimeter of ... Read More
Suppose we have an array that contains some dates like this −const arr = [ [ '02/13/2015', 0.096 ], [ '11/15/2013', 0.189 ], [ '05/15/2014', 0.11 ], [ '12/13/2013', 0.1285 ], [ '01/15/2013', 0.12 ], [ '01/15/2014', 0.11 ], [ '02/14/2014', 0.11 ], [ '03/14/2014', 0.11 ], [ '01/15/2015', 0.096 ], [ '07/15/2015', 0.096 ], [ '04/15/2013', 0.12 ], [ '04/15/2014', 0.11 ], [ '05/15/2013', 0.12 ], [ '06/14/2013', 0.12 ], [ '06/16/2014', 0.11 ], [ '07/15/2013', 0.12 ], [ '07/15/2014', 0.11 ], ... Read More
We are required to write a JavaScript function that takes in an array of strings and returns an object corresponding to the strings.For example −If the array is −const arr = [ "country.UK.level.1", "country.UK.level.2", "country.US.level.1", "country.UK.level.3" ];Then the output should be −const output = { "country": [ {"UK" : {"level" : ["1", "2", "3"]}}, {"US" : {"level" : ["1", "2"]}} ] } ConditionsStrings stored in the str array will not be sorted and the code should be robust against that.Strings will follow the x.y.x.y... pattern, where x will be ... Read More