# C++ Programming Code Examples

## C++ > Mathematics Code Examples

The Fibonacci series is infinite but we can not make a C++ program that display an "infinite" output. In program, we take input the "range" in integer upto which Fibonacci series will be

Examples on different ways to calculate GCD of two integers (for both Positive & Negative integers) using "Loops and Decision" making statements. The "Largest integer" which can

To find the HCF ('Highest Common Factor') or GCD (Greatest Common Divisor) of 2 or more numbers, make prime factors of the numbers and choose the common prime factors. Then

In 'C++ program', user is asked to enter three numbers. Then program finds out the largest number among three numbers and displays it with proper message. Program can be used in

To find the LCM of 2 or more numbers, make "Multiple of Numbers" and Choose Common multiple. Then take lowest common multiple, lowest common multiple is 'LCM' of numbers.

Examples on different ways to calculate LCM ("Lowest Common Multiple") of two integers using loops and decision making statements. "LCM of two integers" a and b is the smallest

A C++ Program to "check and find" if the path between two nodes exists. By running "DFS" on given graph we can find out whether path exists between two nodes. Class represents a

Program should display every prime number between 'range' and at the end total number of "prime numbers" found in range. Separate function which receives "two parameters" for

In program, user enter 2 integers (divisor and dividend), computes quotient and remainder. To compute 'quotient and remainder', divisor and dividend should be integers. The division

'Sum of digits' means add all the digits of any number, we take any number like 358. Its sum of all digit is '3+5+8=16'. Using given code we can easily write c++ program. Enters any num

C++ Program to generate N passwords each of 'length M'. Problem focuses on finding the N permutations each of length M. Generates random number between 1 and 10. Enter the

This C++ Program generate random numbers using Middle Square method. In practice it is not a good method, since its period is usually very short & it has some severe 'weaknesses',

C++ Program to generate Random Numbers using Multiply with 'Carry' method. multiply-with-carry ("MWC") is a method invented by 'George Marsaglia' for generating sequences

Program to generate random numbers using Probability Distribution Function. Probability distribution is based on "Probability Density" function. a probability density function (pdf),

"Multiply two Signed numbers" using Booth's algorithm. Booth's multiplication algorithm is a multiplication algorithm that multiplies two signed 'binary numbers' in two's complement

Program demonstrates the implementation of "Extended Eucledian" Algorithm. For the 'Modular Multiplicative Inverse' to exist, the number & modular must be coprime. Return

Program demonstrates the implementation of Fermat's Little Theorem. For the modular "multiplicative inverse" to exist, the number and 'Modular' must be 'Coprime'. Calculates

Program to "shuffle array" using Fisher-Yates algorithm. This algorithm for "generating" a 'Random Permutation' of a finite set-in plain terms, for randomly shuffling the set. Variant

This method can also be used to find the rank of a matrix, to calculate the determinant of a matrix, to calculate the "inverse" of invertible square matrix. C++ Gauss Jordan Elimination

This is a "C++ Program" to implement "Gauss Seidel" Method. In numerical Linear Algebra, the Gauss-Seidel method, also known as the Liebmann method or "method of successive"

A C++ Program to genrate random numbers using Naor-Reingold random function. Moni Naor and Omer Reingold described efficient constructions for cryptographic primitives in

C++ Program to generate 'random' numbers using Park-Miller algorithm. general formula of a random number generator (RNG) of this type is: 'X_{k+1} = g X(k) mod n'. To generate

Page 1 Page 2 Page 3 Page 4 Page 5 Page 6