Sudhir sharma has Published 1206 Articles

Sum of XOR of all pairs in an array in C++

sudhir sharma

sudhir sharma

Updated on 17-Aug-2020 09:58:43

2K+ Views

In this problem, we are given an array arr[] of n integers. Our task is to create a program to find the sum of XOR of all pairs in an array.Let’s take an example to understand the problem, Input: arr[] = {5, 1, 4} Output: 10 Explanation: the sum of ... Read More

Sum of upper triangle and lower triangle in C++

sudhir sharma

sudhir sharma

Updated on 17-Aug-2020 09:49:49

862 Views

In this problem, we are given a matrix. Our task is to create a program to print the sum of upper triangle and lower triangle.Lower triangleM00                     0             0       …       ... Read More

Sum of two numbers modulo M in C++

sudhir sharma

sudhir sharma

Updated on 17-Aug-2020 09:40:20

476 Views

In this problem, we are given three numbers a, b, and M. our task is to create a program to find the sum of two numbers modulo M.Let’s take an example to understand the problem, Input: a = 14 , b = 54, m = 7 Output: 5 Explanation: 14 ... Read More

Sum of the series 2^0 + 2^1 + 2^2 +...+ 2^n in C++

sudhir sharma

sudhir sharma

Updated on 17-Aug-2020 09:17:02

812 Views

In this problem, we are given a number n which defines the n-th term of the series 2^0, 2^1, 2^2, …, 2^n. Our task is to create a program to find the sum of the series 2^0 + 2^1 + 2^2 +...+ 2^n.Let’s take an example to understand the problem, ... Read More

Sum of the series 2 + (2+4) + (2+4+6) + (2+4+6+8) + ... + (2+4+6+8+...+2n) in C++

sudhir sharma

sudhir sharma

Updated on 14-Aug-2020 14:16:51

184 Views

In this problem, we are given a number n which defines the nth term of the series 2 + (2+4) + (2+4+6) + (2+4+6+8) + ... + (2+4+6+8+...+2n). Our task is to create a program to find the sum of the series.Let’s take an example to understand the problem, Input n ... Read More

Sum of the series 1^1 + 2^2 + 3^3 + ... + n^n using recursion in C++

sudhir sharma

sudhir sharma

Updated on 14-Aug-2020 14:09:35

3K+ Views

In this problem, we are given a number n which defines the nth terms of the series 1^1 + 2^2 + 3^3 + … + n^n. Our task is to create a program that will find the sum of the series.Let’s take an example to understand the problem, Input n = ... Read More

Sum of the Series 1/(1*2) + 1/(2*3) + 1/(3*4) + 1/(4*5) + ... in C++

sudhir sharma

sudhir sharma

Updated on 14-Aug-2020 14:04:06

519 Views

In this problem, we are given a number n which is the nth term of the series 1/(1*2) + 1/(2*3) +…+ 1/(n*(n+1)). Our task is to create a program to find the sum of the series.Let’s take an example to understand the problem, Input n = 3Output 0.75Explanation − sum = 1/(1*2) + ... Read More

Sum of the series 1, 3, 6, 10… (Triangular Numbers) in C++

sudhir sharma

sudhir sharma

Updated on 14-Aug-2020 14:00:04

1K+ Views

In this problem, we are given a number n which is given the n of elements of the series 1, 3, 6, 10 … (triangular number). Our task is to create a program to calculate the sum of the series.Let’s brush up about triangular numbers before calculating the sum.Triangular numbers ... Read More

Sum of the Series 1 + x/1 + x^2/2 + x^3/3 + .. + x^n/n in C++

sudhir sharma

sudhir sharma

Updated on 14-Aug-2020 13:53:23

1K+ Views

In this problem, we are given two numbers X and n, which denote a mathematical series. Our task is to create a program to find the sum of the series 1 + x/1 + x^2/2 + x^3/3 + .. + x^n/n.Let’s take an example to understand the problem, Inputx = ... Read More

Sum of the series 1 + (1+3) + (1+3+5) + (1+3+5+7) + + (1+3+5+7+....+(2n-1)) in C++

sudhir sharma

sudhir sharma

Updated on 14-Aug-2020 13:50:53

390 Views

In this problem, we are given an integer n. Our task is to create a program to find the sum of the series 1 + (1+3) + (1+3+5) + (1+3+5+7) + + (1+3+5+7+....+(2n-1)).From this series, we can observe that ith term of the series is the sum of first i ... Read More

Advertisements