Server Side Programming Articles - Page 1794 of 2646

Complex Number Multiplication in C++

Arnab Chakraborty
Updated on 04-May-2020 12:58:28

2K+ Views

Suppose we have two strings that are representing complex numbers, we have to parse them and perform complex number multiplication, then return result as a string.So if the input is like “1+-1i” and “1+-1i”, then the result will be “0+-2i”.To solve this, we will follow these steps −aa := a pair of real and imaginary of first complex numberbb := a pair of real and imaginary of second complex numberx := aa.real * bb.real – aa.img*bb.imgy := aa.real * bb.img + aa.img*bb.realreturn the string as “x+yi”Let us see the following implementation to get better understanding −Example Live Demo#include using namespace ... Read More

Program to find N-th term of series 2, 12, 28, 50, 77, 112, 152, 198, …in C++

Ayush Gupta
Updated on 03-Oct-2020 09:39:55

112 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 2, 12, 28, 50, 77, 112, 152, 198, …in C++.Problem Description − To find the N-th term of the series.2, 12, 28, 50, 77, 112, 152, 198, ...N termsWe will find a general for the series.Let’s take an example to understand the problem, Input − N = 6Output − 112Solution Approach:Here, the series is increasing in parabolic form, so the general term will be a quadratic equation.So, the general formula for the series isTN = 3*(N*N) + N ... Read More

Program to find N-th term of series 0, 11, 28, 51, 79, 115, 156, 203, …In C++

Ayush Gupta
Updated on 03-Oct-2020 09:40:40

141 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 0, 11, 28, 51, 79, 115, 156, 203, … In C++.Problem Description − To find the Nth terms of the series −0, 11, 28, 51, 79, 115, 156, 203, … N-th term.Let’s take an example to understand the problem,Input − N = 5Output − 79Solution Approach:The general formula for nth term of the series is −Tn = 3*(N*N) + 2*N - 5Program to illustrate the working of our solution,#include using namespace std; int findNTerm(int N) { int nthTerm = ( (3*N*N) + 2*N - 5); return nthTerm; } int main() { int N = 9; cout

Program to find N-th term of series 1, 3, 12, 60, 360...in C++

Ayush Gupta
Updated on 03-Oct-2020 09:41:34

203 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 1, 3, 12, 60, 360...in C++.Given Series1, 3, 12, 60, 360, 2520 … N TermsLet’s take an example to understand the problem, Input − N = 6Output − 2520Solution Approach:The general term formula for this one is a bit tricky. So, the increase in the series values is huge. So, there can be a few possibilities factorial or exponentials. So, we will first consider factorial, and on observing we can see the growth half as half of the ... Read More

Program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …in C++

Ayush Gupta
Updated on 04-May-2020 12:28:24

154 Views

In this tutorial, we will be discussing a program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of given series int nthTerm(int n) {    return 3 * pow(n, 2) - 4 * n + 2; } int main() {    int N = 4;    cout

Program to find N-th term of series 0, 9, 22, 39, 60, 85, 114, 147, …in C++

Ayush Gupta
Updated on 03-Oct-2020 09:43:31

184 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 0, 9, 22, 39, 60, 85, 114, 147, …in C++.Problem Description − We are given the Series −0, 9, 22, 39, 60, 85, 114, 147, ....NtermsTo find the Nth term of this series, we will formula the general term of the series and then find the Nth term.Let’s take an example to understand the problem, Input − N = 6Output − 85Solution Approach:To find the general term of the series. Let’s observe the growth of the values of ... Read More

Program to find N-th term of series 0, 10, 30, 60, 99, 150, 210, 280...in C++

Ayush Gupta
Updated on 04-May-2020 12:25:49

191 Views

In this tutorial, we will be discussing a program to find N-th term of series 0, 10, 30, 60, 99, 150, 210, 280...For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of series int nthTerm(int n) {    return 5 * pow(n, 2) - 5 * n; } int main() {    int N = 4;    cout

Program to find N-th term of series 0, 7, 8, 33, 51, 75, 102, 133...in C++

Ayush Gupta
Updated on 04-May-2020 12:24:15

136 Views

In this tutorial, we will be discussing a program to find N-th term of series 0, 7, 8, 33, 51, 75, 102, 133...For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of series int nthTerm(int n) {    return 2 * pow(n, 2) + n - 3; } int main() {    int N = 4;    cout

Program to find N-th term of series 0, 2,1, 3, 1, 5, 2, 7, 3...in C++

Ayush Gupta
Updated on 03-Oct-2020 09:46:30

205 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 0, 2, 1, 3, 1, 5, 2, 7, 3...in C++.Problem Description − We are given the Series −0, 2, 1, 3, 1, 5, 2, 7, 3...N TermTo find the Nth term of this series, we will formula the general term of the series and then find the Nth term.Let’s take an example to understand the problem, Input − N = 7Output − 2Solution Approach :To solve the problem and find the general formula for the series. We need ... Read More

Program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++

Ayush Gupta
Updated on 09-Oct-2020 06:38:22

244 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++.Problem descriptionTo find the Nth term of the given series−0, 0, 2, 1, 4, 2, 6, 3, 8 .... N TermsWe will find the general term of the series.Let’s take an example to understand the problem, InputN = 8Output3Solution ApproachTo find the general term of the series, we need to closely observe the series. This series is a bit difficult to recognize as it is a mixture of two ... Read More

Advertisements