Server Side Programming Articles - Page 2082 of 2650

C++ program to find the quantity after mixture replacement

Ayush Gupta
Updated on 21-Nov-2019 12:54:02

97 Views

In this tutorial, we will be discussing a program to find the quantity of milk left after mixture replacement.Let us suppose we have X litres of milk. From that, Y litres of milk is replaced with Y litres of water itself. This same procedure is done again and again Z number of times. Our task is to find the final amount of milk left in the container.Finding the relation among the values between the repetitive operations, we find the formula for finding the amount of milk after Z number of operations to beamount left = ((X-Y)/X)Z*XExample#include using namespace std; ... Read More

C Program for Hexagonal Pattern

Sunidhi Bansal
Updated on 21-Nov-2019 12:28:19

2K+ Views

We are given with an integer ‘n’ and the task is to generate the hexagonal pattern and display the final output.ExampleInput-: n=5 Output-:Input-: n = 4 Output-:Approach we are using in the given program is as follows −Input the number ‘n’ from userDivide the entire pattern into three parts i.e. upper part, middle part and lower part Start loop i for printing the upper part of the pattern from i to 0 and i to be less than n and keep incrementing the value of i Start loop m for printing the middle part of the pattern from m to ... Read More

C++ Program for class interval arithmetic mean

Sunidhi Bansal
Updated on 09-Jul-2020 08:44:06

677 Views

We are given with three arrays where first array contains the upper limit for arithmetic mean, second array contains the lower limit for arithmetic mean and third array contains the frequencies and the task is to generate the arithmetic mean of class intervals given.What is Arithmetic Mean?Arithmetic mean is the average value that is calculated by dividing the sum of all the elements in the set with the total number of elements in the given set.How to calculate Class Interval Arithmetic MeanGiven with Lower Limit, Upper Limit, FrequencyLower LimitUpper LimitFrequency121342563784Calculate the mid-point by adding the upper limit and lower limit ... Read More

C Program for Circumference of a Parallelogram

Sunidhi Bansal
Updated on 09-Jul-2020 08:45:53

200 Views

We are given with the sides of parallelogram and the task is to generate the circumference of a parallelogram with its given sides and display the resultWhat is a Parallelogram?Parallelogram is a type of quadratic which have −Opposite sides parallelOpposite angles equalPolygon diagonals bisects each otherShown in the below figure ‘a’ and ‘b’ are the sides of a parallelogram where parallel sides are shown in the figure.Perimeter/Circumference of a parallelogram is defined as −Circumference of Parallelogram = 2(a + b)                                           ... Read More

C program for Binomial Coefficients table

Sunidhi Bansal
Updated on 09-Jul-2020 08:48:19

8K+ Views

Given with a positive integer value let’s say ‘val’ and the task is to print the value of binomial coefficient B(n, k) where, n and k be any value between 0 to val and hence display the result.What is Binomial CoefficientBinomial coefficient (n, k) is the order of choosing ‘k’ results from the given ‘n’ possibilities. The value of binomial coefficient of positive n and k is given by$$C_k^n=\frac{n!}{(n-k)!k!}$$where, n >= kExampleInput-: B(9, 2) Output-:$$B_2^9=\frac{9!}{(9-2)!2!}$$ $$\frac{9\times 8\times 7\times 6\times 5\times 4\times 3\times 2\times 1}{6\times 5\times 4\times 3\times 2\times 1)\times 2\times 1}=\frac{362, 880}{1440}=252$$What is Binomial Coefficient TableThe Binomial Coefficient Table is formed ... Read More

C++ Program for Deadlock free condition in Operating Systems

Sunidhi Bansal
Updated on 09-Jul-2020 08:50:06

4K+ Views

Given with the P number of processes in the memory and N number of needed resources by them to complete their execution and the task is to find the minimum number of resources R which should be allotted to the processes such that deadlock will never occur.What is a DeadlockDeadlock is situation in an operating system where multiple processes residing in the memory doesn’t able to perform their execution because the resources which are needed for program execution is being hold by another resource who is waiting for some other resource for completion.Let’s say there are two processes P1 and ... Read More

C++ program for Find sum of odd factors of a number

Sunidhi Bansal
Updated on 09-Jul-2020 08:22:32

573 Views

Given with a positive integer and the task is to generate the odd factors of a number and finding out the sum of given odd factors.ExampleInput-: number = 20 Output-: sum of odd factors is: 6 Input-: number = 18 Output-: sum of odd factors is: 13So, result = 1 + 5 = 6Approach used in the below program is as follows −Input the number for calculating the sum of odd factors of that numberIgnore the digit 0 and 2 because both are even digits and store the digit 1 because it is an odd digitStart the loop from 3 ... Read More

C++ Program for triangular pattern (mirror image around 0)

Sunidhi Bansal
Updated on 09-Jul-2020 08:23:06

346 Views

Given with the positive value n and the task is to generate the triangular pattern i.e. mirror image of the printed numbers and display the resultExampleInput-: n = 6 Output-:Input-: n = 3 Output-:Approach used in the below program is as follows −Input the value of n as a positive integerTraverse one loop i for the number of rows in a pattern i.e. nTraverse one loop j for the number of spaces in a patternTraverse another loop for the digits in a patternAlgorithmSTART Step 1-> declare function to print mirror image of triangular pattern    void print_mirror(int n)    declare ... Read More

C++ Program for converting hours into minutes and seconds

Sunidhi Bansal
Updated on 09-Jul-2020 08:23:37

1K+ Views

Given with the input as hours and the task is to convert the number of hours into minutes and seconds and display the corresponding resultFormula used for converting the hours into minutes and seconds is −1 hour = 60 minutes    Minutes = hours * 60 1 hour = 3600 seconds    Seconds = hours * 3600ExampleInput-: hours = 3 Output-: 3 hours in minutes are 180    3 hours in seconds are 10800 Input-: hours = 5 Output-: 5 hours in minutes are 300    5 hours in seconds are 18000Approach used in the below program is as follows ... Read More

C++ Program to calculate the value of sin(x) and cos(x)

Sunidhi Bansal
Updated on 20-Nov-2019 13:07:30

5K+ Views

Given with the input as angles and the task is to calculate the value of sin(x) and cos(x) corresponding to the given angle and display the resultFor Sin(x)Sin(x) is a trigonometric function which is used to calculate the value of x angle.Formula$$\sin (x) = \displaystyle\sum\limits_{k=0}^\infty \frac{(-1)^{k}}{(2k+1)!}x^{2k+1}$$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}$$Approach used in the below program is as follows −Input the value of x angle for sin(x) and cos(x)Apply the formulas given for sin(x) and cos(x)Print the resultALGORITHMSTART Step 1-> declare function to calculate value of ... Read More

Advertisements