C++ Program to Implement Sieve of Eratosthenes

What is Sieve of Eratosthenes? The Sieve of Eratosthenes in C++ is a method to find prime numbers. It makes a list of numbers and eliminates multiples of each prime number, leaving only the prime numbers behind. It’s an efficient way to find primes. Example: Let’s use the Sieve of Eratosthenes to find prime numbers … Read more

advertisement

C++ Program to Solve any Linear Equation in One Variable

This is a C++ Program that Solves any Linear Equation in One Variable. Problem Description The Problem states that given a linear equation in one variable of the form aX + b = cX + d where a,b,c,d are provided as input, we need to determine the appropriate value of X. Problem Solution Solving the … Read more

advertisement

C++ Program to Compute Discrete Fourier Transform using Fast Fourier Transform Approach

This is a C++ Program to perform Fast Fourier Transform. A fast Fourier transform (FFT) is an algorithm to compute the discrete Fourier transform (DFT) and its inverse. Fourier analysis converts time (or space) to frequency and vice versa; an FFT rapidly computes such transformations by factorizing the DFT matrix into a product of sparse … Read more

advertisement

C++ Program to Implement Fisher-Yates Algorithm

This is a C++ Program to shuffle array using Fisher-Yates algorithm. The Fisher–Yates shuffle (named after Ronald Fisher and Frank Yates), also known as the Knuth shuffle (after Donald Knuth), is an algorithm for generating a random permutation of a finite set—in plain terms, for randomly shuffling the set. A variant of the Fisher–Yates shuffle, … Read more

advertisement

C++ Program to Solve the Fractional Knapsack Problem

This is a C++ Program to solve fractional knapsack. The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items, each with a mass and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to … Read more

advertisement

C++ Program to Implement Gauss Jordan Elimination

This is a C++ Program to implement Gauss Jordan Elimination algorithm. In linear algebra, Gaussian elimination (also known as row reduction) is an algorithm for solving systems of linear equations. It is usually understood as a sequence of operations performed on the associated matrix of coefficients. This method can also be used to find the … Read more

advertisement

C++ Program to Implement Gauss Seidel Method

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 the method of successive displacement, is an iterative method used to solve a linear system of equations. Here is source code of the C++ Program to Implement Gauss Seidel Method. The … Read more

advertisement

C++ Program to Find GCD of Two Numbers Using Recursive Euclid Algorithm

This is a C++ Program to find GCD of two numbers using Recursive Euclid Algorithm. In mathematics, the Euclidean algorithm, or Euclid’s algorithm, is a method for computing the greatest common divisor (GCD) of two (usually positive) integers, also known as the greatest common factor (GCF) or highest common factor (HCF). It is named after … Read more

advertisement

C++ Program to Generate Random Hexadecimal Bytes

This is a C++ Program to generate random hex bytes. The idea is to genrate decimal number first and convert it to hexadecimal. Here is source code of the C++ Program to Generate Random Hexadecimal Bytes. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below. … Read more

advertisement

C++ Program to Implement Linear Congruential Method for Generating Pseudo Random Number

This is a C++ Program to generate random numbers using Linear Congruential Generator. A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. The method represents one of the oldest and best-known pseudorandom number generator algorithms. The theory behind them is relatively easy … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.