Calculate Profit Sharing Ratio in C++

Sunidhi Bansal
Updated on 20-Nov-2019 12:44:56

507 Views

Given with an array of amount invested by multiple person and another array containing the time period for which money is invested by corresponding person and the task is to generate the profit sharing ratio.What is Profit Sharing RatioIn a partnership firm, profits and losses are shared between the partners depending upon the capital invested by them in the business. On the basis of that capital investment percentage we calculate the profit sharing ratio which shows the amount of profit which is to be given to each partner of a business.Formula − Partner 1 = capital invested * time period ... Read More

Calculate Number of Odd Days in Given Number of Years Using C++

Sunidhi Bansal
Updated on 20-Nov-2019 12:34:50

255 Views

Given with the positive integer value n and the task is to generate the number of odd days till the given year n.ExampleInput-: days = 500 Output-: number of odd days are: 5 Input-: days = 400 Output-: number of odd days are: 0How to calculate the number of odd days in given number of yearsFor calculating the number of odd days the first thing we need to check is whether the given year is a leap year or not because if it’s a leap year than the number of odd days will get changed. If the year is divisible ... Read More

C++ Program to Calculate Double Integration

Sunidhi Bansal
Updated on 20-Nov-2019 12:32:21

2K+ Views

We are given with the lower limit of variable x, upper limit of variable x, lower limit of variable y, upper limit of variable y, steps taken for corresponding x and steps taken for corresponding y and the task is to generate the double integration and display the result.ExampleInput-: steps for x = 1.2 steps for y = 0.54 lower limit of x = 1.3 upper limit of x = 2.1 lower limit of y = 1.0 upper limit for y = 2.1 Output-: double integration is : 2.1Approach used in the below program is as follows −Input the value ... Read More

Probability for Three Randomly Chosen Numbers to be in AP

Sunidhi Bansal
Updated on 20-Nov-2019 12:24:58

216 Views

Given with an array of numbers ‘n’ and the task is to find the probability of three randomly chosen numbers to be in AP.ExampleInput-: arr[] = { 2, 3, 4, 7, 1, 2, 3 } Output-: Probability of three random numbers being in A.P is: 0.107692 Input-:arr[] = { 1, 2, 3, 4, 5 } Output-: Probability of three random numbers being in A.P is: 0.151515Approach used in the below program is as follows −Input the array of positive integersCalculate the size of the arrayApply the formula given below to find the probability of three random numbers to be in ... Read More

C Program for Sum of Cos X Series

Sunidhi Bansal
Updated on 20-Nov-2019 12:23:00

5K+ Views

We are given with the value of x and n where, x is the angle for cos and n is the number of terms in the cos(x) series.For Cos(x)Cos(x) is a trigonometric function which is used to calculate the value of x angle.Formula$$\cos (x) = \displaystyle\sum\limits_{k=0}^\infty \frac{(-1)^{k}}{(2k!)}x^{2k}$$For Cos(x) seriesCos(x) = 1 – (x*2 / 2!) + (x*4 / 4!) – (x*6 / 6!) + (x*8 / 8!)……ExampleInput-: x = 10, n = 3 Output-: 0.984804 Input-: x = 8, n = 2 Output-: 0.990266Approach used in the below program is as follows −Input the value of x and nApply the ... Read More

C Program for Nth Catalan Number

Sunidhi Bansal
Updated on 20-Nov-2019 12:19:33

2K+ Views

Given an interger n; the task is to find the Catalan Number on that nth position. So, before doing the program we must know what is a Catalan Number?Catlan numbers are the sequence of natural numbers, which occurs in the form of various counting number problems.Catalan numbers C0, C1, C2, … Cn are driven by formula −$$c_{n}=\frac{1}{n+1}\binom{2n}{n} = \frac{2n!}{(n+1)!n!}$$The few Catalan numbers for every n = 0, 1, 2, 3, … are 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, …So if we entered n =3 we should get 5 as an output from the programSome of few ... Read More

C++ Program for Quotient and Remainder of Big Number

Sunidhi Bansal
Updated on 20-Nov-2019 12:15:19

427 Views

Given a sting of a big number say num and another big number say m; the task is to print the quotient using divide operation and the remainder of the big number using modulus.The output should be Remainder = xxx; Quotient = yyyLet’s assume we have an input num = string num = "14598499948265358486" and other input m = 487 so the remainder is 430 and quotient is 29976385930729688.ExampleInput: num = “214755974562154868”    m = 17 Output: Remainder = 15    quotient = 12632704386009109 Input: num =“214”    m = 5 Output: Remainder = 4    Quotient = 42Approach we ... Read More

C Program to Print a Number in Large Size

Sunidhi Bansal
Updated on 20-Nov-2019 11:53:00

426 Views

Given a number n in form of a string; the task is to print that following number in large using hash symbols.Like we have provided a number “1234”The representation of the following number should be −Likewise we want our solution to be printed −ExampleInput: n[] = {“2234”} Output:Input: n[] = {“987”} Output:Approach we will be using to solve the given problem −Take at most 4 digit number a input in a string.Make arrays of every number one by one the large pattern we want for the number.Traverse the string and print every number one by one.AlgorithmStart    Step 1 -> ... Read More

Check If a Number Belongs to a Particular Base in C

Sunidhi Bansal
Updated on 20-Nov-2019 11:27:45

1K+ Views

Given a number as a string and a base; the task is to check whether the given number of is of that given base or not.We have to check the number and the base according to the number system in which there are bases like 2 for a binary number, 8 for an octal number, 10 for decimal number and 16 for a Hexadecimal number. According to this we have to find whether the given number in a string belongs to a particular base or not, If it belongs to a particular base then we have to print “Yes” on ... Read More

C Program for N-th Term of Arithmetic Progression Series

Sunidhi Bansal
Updated on 20-Nov-2019 11:10:57

9K+ Views

Given ‘a’ the First term, ‘d’ the common difference and ‘n’ for the number of terms in a series. The task is to find the nth term of the series.So, before discussing how to write a program for the problem first we should know what is Arithmetic Progression.Arithmetic progression or arithmetic sequence is a sequence of number where the difference between the two consecutive terms is same.Like we have first term i.e a =5, difference 1 and nth term we want to find should be 3. So, the series would be: 5, 6, 7 so the output must be 7.So, ... Read More

Advertisements