Found 1401 Articles for C

Sum of all subsets of a set formed by first n natural numbers

sudhir sharma
Updated on 19-Aug-2019 08:35:14

142 Views

A Set is a collection of data elements. Subset of a set is a set formed by only the elements after parent set. for example, B is A subset of a if all elements of B exist in A.Here we need to find the sum of all subsets of a set found by first n natural numbers. this means I need to find all subsets that can be formed and then adding them. Let's take an example, N = 3Set = {1, 2, 3}subsets formed = { {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3, } ... Read More

Sum of series with alternate signed squares of AP

sudhir sharma
Updated on 19-Aug-2019 08:33:11

201 Views

An arithmetic progression (AP) is a series of numbers in which the difference between two consecutive terms in the same. The difference is calculated by subtracting the second term from the first.Let's take a sample sequence to know about AP, 5, 7, 9, 11, 13, 15, . . . The common difference(d) of this arithmetic progression is 2. This means every succeeding element differs the former one by 2. The first term (a) of this series is 5.The general formula for finding the nth term is a{n} = a + (n-1)(d)In this problem, we are given an AP and we ... Read More

Sum of series 2/3 – 4/5 + 6/7 – 8/9 + …… upto n terms

sudhir sharma
Updated on 19-Aug-2019 08:30:52

361 Views

A series is a sequence of numbers that have some common traits that each number follows. There are various series defined in mathematics with sum mathematical logic or mathematical formula. In this problem we are given a series of numbers 2/3 , -4/5 , 6/7 , -8/9 , …..The general term of the series can be defined as (-1)n *(2*n)/ ((2*n)+1)To find the sum of series, we need to add each element of the given series as, 2/3 - 4/5 + 6/7 - 8/9 + ……Let's take an example, Input: 10 Output: -0.191921Explanation(2 / 3) - (4 / 5) + ... Read More

Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n – 1)^2

sudhir sharma
Updated on 19-Aug-2019 08:27:31

153 Views

A series is a sequence of numbers that have some common traits that each number follows. These mathematical series are defined based on some mathematical logic like every number increases by the same interval( arithmetic progression), every number is increased by the same multiple( geometric progression), and many other patterns.To find the sum of a series we need to evaluate the series and make a general formula for it. But in the series that is no common declaration that takes place so we have to go through the classical approach by adding each number of the series to a sum ... Read More

C Program to Check Whether a Number is Prime or not?

sudhir sharma
Updated on 07-Nov-2023 05:31:12

36K+ Views

A prime number is a number that is divisible only by two numbers itself and one. The factor of a number is a number that can divide it.The list of the first ten prime numbers is 2, 3, 5, 7, 11, 13, 17, 23, 29, 31.A number that is not prime is a composite number. A composite number is a number that can be divided by more than two numbers.Else then prime and composite there is 1 which is neither Prime nor composite because it can be divided only by itself.How to check if a number is prime or composite ... Read More

C Program for Selection Sort?

sudhir sharma
Updated on 02-Sep-2023 11:53:29

81K+ Views

The selection sort is assaulting algorithm that works bye buy a finding the smallest number from the array and then placing it to the first position. the next array that is to be traversed will start from index next to the position where the smallest number is placed.Let's take an example to make this concept more clear.We have an array {6, 3, 8, 12, 9} in this array the smallest element is 3. So we will place 3 at the first position, after this the array will look like {3, 6, 8, 12, 9}. Now we will again find the ... Read More

C Program for Find the largest prime factor of a number?

sudhir sharma
Updated on 19-Aug-2019 07:55:07

4K+ Views

Prime Factor− In number theory, the prime factors of a positive integer are the prime numbers that divide that integer exactly. The process of finding these numbers is called integer factorization, or prime factorization.Example− Prime factors of 288 are: 288 = 2 x 2 x 2 x 2 x 2 x 3 x 3Input: n = 124 Output: 31 is the largest prime factor!ExplanationYou will find all the prime factors of a number and find the largest of them. The prime factors 124 = 2 x 2 x 31. and 31 is the largest of them.Example#include int main() { ... Read More

C/C++ Program to Find the reminder of array multiplication divided by n?

sudhir sharma
Updated on 19-Aug-2019 12:58:56

109 Views

Array multiplication we will find the product of all elements of the given array. and then according to the problem, we will divide the product with the number n. let's take an example −Input: arr[] = { 12, 35, 69, 74, 165, 54};       N = 47 Output: 14ExplanationThe array is like {12, 35, 69, 74, 165, 54} so the multiplication will be (12 * 35 * 69 * 74 * 165 * 54) = 19107673200. Now if we want to get the remainder after dividing this by 47 it will be 14.First multiple all the number then ... Read More

C/C++ Program to find the Product of unique prime factors of a number?

sudhir sharma
Updated on 19-Aug-2019 07:45:29

282 Views

The unique prime factors is a factor of the number that is a prime number too. In this problem, we have to find the product of all unique prime factors of a number. A prime number is a number that has only two factors, the number and one.Here we will try to find the best way to calculate the product of unique prime factors of a number. let's take an example to make the problem more clear.There is a number say n = 1092, we have to get the product of unique prime factors of this. The prime factors of ... Read More

C/C++ Program to the Count set bits in an integer?

sudhir sharma
Updated on 19-Aug-2019 07:43:40

145 Views

Counting set bits means counting 1’S of the given integer. For this, we have multiple solutions that can be applied. For this case, we have a binary number( binary representation of an integer), for which we have to count the number of 1’s off the string.To count the number of 1’s, we will take the string, traverse each element and count all the 1’s of the string. For example, if we input 17 the output will be 2 because the binary of 17 is 10001 that contains two 1's.Input: Enter a positive integer: 6 Output: 2ExplanationThe binary representation of 6 ... Read More

Advertisements