Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
C++ Articles
Page 276 of 597
Sum of squares of binomial coefficients in C++
The binomial coefficient is a quotation found in a binary theorem which can be arranged in a form of pascal triangle it is a combination of numbers which is equal to nCr where r is selected from a set of n items which shows the following formulanCr=n! / r!(n-r)! or nCr=n(n-1)(n-2).....(n-r+1) / r!The sum of the square of Binomial Coefficient i.e (nC0)2 + (nC1)2 + (nC2)2 + (nC3)2 + ……… + (nCn-2)2 + (nCn-1)2 + (nCn)2Input :n=5 Output:252ExplanationIn this program first we have to find the binomial coefficient of r which is selected from n set then we have to ...
Read MoreSum of squares of Fibonacci numbers in C++
Fibonacci series is a mathematical sequence of number which starts from 0 and the sum of two numbers is equal to the next upcoming number, for example, the first number is 0 and the second number is 1 sum of 0 and 1 will be 1F0=0, F1=1AndFn=Fn-1+Fn-2, F2=F0+F1 F2=0+1 F2=1then when we add number 1 and 1 then the next number will be 2F1=1, F2=1AndFn=Fn-1+Fn-2, F3=F1+F2 F3=1+1 F3=2Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …We have to find the square of the fuel energy series and then we have to sum it and find ...
Read MoreC/C++ Ternary Operator
Syntax of ternary operator is −(expression-1) ? expression-2 : expression-3This operator returns one of two values depending on the result of an expression. If "expression-1" is evaluated to Boolean true, then expression-2 is evaluated and its value is returned as a final result otherwise expression-3 is evaluated and its value is returned as a final result.ExampleLet us write a program to find maximum of two numbers using ternary operator.#include using namespace std; int main() { int a = 10; int b = 20; int max = a > b ? a : b; cout
Read MoreAdd N digits to A such that it is divisible by B after each addition in C++?
Here we will see how to generate a number A by adding N digits with it, and while adding new digits in each stage it will be divisible by another number B. Let us consider we are going to make a 5-digit number by adding 4 extra digits with it. We will check the divisibility by 7. The number will start from 8. So at first it will append 4 with it, so the number will be 84, that is divisible by 7. Then add 0 with the number so it will remain divisible by 7. If the number cannot ...
Read MoreAnonymous classes in C++
Anonymous entity is anything that is defined without a name. A class with no name provided is known as an anonymous class in c++. An anonymous class is a special class with one basic property.As there is no name given to the class there is no constructor allocated to it, though a destructor is there for deallocating the memory block.The class cannot be used as an element of a function i.e. you cannot pass it as an argument or cannot accept values return from the function.The syntax for defining an anonymous class in c++class { //data members // ...
Read MoreArea of a Circumscribed Circle of a Square in C++
In this problem, we will calculate the area of the circumscribed circle of a square when we are given the side of the square. Before we go further let’s revise the basic definitions to understand the concepts better.Square is a quadrilateral with all sides equal.The circumscribing circle is a circle touches all the vertices of a polygon.The area is the quantitative representation of the extent of any two-dimensional figure.To calculate the area of the circumscribed circle of a square. We need to find the relation between the parameter of the circle and the square.Now, as in the figure, all the ...
Read MoreAliquot Sequence in C++
Aliquot sequence is a special sequence of numbers. The sequence starts from the number itself and the next number of the sequence is the sum of the proper divisors of the previous terms.Let’s take an example of the sequence to learn the concept better −Input : 8 Output : 8 7 1 0 Explanation : Proper divisors of 8 are 4, 2, 1. The sum is 7 Proper divisors of 7 are 1. The sum is 1 Proper divisors of 1 are 0. The sum is 0Perfect number is the number that has the aliquot sequence of ...
Read MoreC++ program to find uncommon characters in two given strings
In this article, we will be discussing a program to find out the uncommon characters during comparison of two different given strings.As we know, strings are nothing but an array of characters. Therefore, for comparison we would be traversing through the characters of one string and simultaneously checking if that element exists in the other string.If we let the first string be A and the second string B.Then it would give us A - B. Similarly we can calculate B - A.Combining both of these results we would get( A - B ) ∪ ( B - A )i.e the ...
Read MoreCheck if a number can be expressed as 2^x + 2^y in C++
Here we will see, if we can represent a number as sum of two non-zero powers of 2. So we will check the given number N can be represented as (2x + 2y) where x, y > 0. Suppose a number is 10, this can be represented as 23 + 21.The approach is simple. There are two cases. If the number n is even, it can be represented as 2x. Where x > 0. Another case is that is N is odd, it can never be represented as sum of powers of 2. We cannot use power as 0, so ...
Read MoreArc length from given Angle in C++?
An Angle is formed when two rays meet at a point. The point on the plane at which these rays meet is vertex.Arc of a circle is a portion of the circumference that is described by an angle.In this problem, we are given an angle of the circle. And we need to find the length of arc using the given diameter of the circle. For example, Input : Angle = 45° Diameter = 28 Output : Arc = 11ExplanationLength of arc = (circumference) X (angle/360°)= (π * d)*(angle/360°)To make a program that calculates the length of Arc from the given ...
Read More