C Program to Solve the Fractional Knapsack Problem

This is a C Program to solve fractional knapsack problem. 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 … Read more

advertisement

C Program to Solve the 0-1 Knapsack Problem

This is a C Program to solve 0-1 knapsack problem. 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 … Read more

advertisement

C Program to Implement Booth’s Multiplication Algorithm for Multiplication

This is a C Program to 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 notation. Booth used desk calculators that were faster at shifting than adding and created the algorithm to increase their speed. Booth’s algorithm is of interest in … Read more

advertisement

C Program to Find GCD of Two Numbers

GCD stands for Greatest Common Divisor. GCD of two numbers in C is the largest positive integer that completely divides both the given numbers. Example: GCD(10,15) = 15, GCD(12,15) = 3. Problem Description Write a C Program to Find the GCD of two numbers. Problem Solution 1. Take two numbers as input. 2. Find the … Read more

advertisement

C Program to Implement Rabin-Miller Primality Test to Check if a Number is Prime

This C program implements the Rabin-Miller Primality Test to check if a given number is Prime. The Miller–Rabin primality test or Rabin–Miller primality test is a primality test: an algorithm which determines whether a given number is prime, similar to the Fermat primality test and the Solovay–Strassen primality test. Here is the source code of … Read more

advertisement

C Program to Implement Sieve of Eratosthenes to Generate Prime Numbers

This C program is used to implement Sieve of Eratosthenes to generate prime numbers between given range. The Sieve of Eratosthenes is a simple algorithm that finds the prime numbers up to a given integer. Implement this algorithm, with the only allowed optimization that the outer loop can stop at the square root of the … Read more

advertisement

C Program to Implement Park-Miller Random Number Generation Algorithm

This C program implements Park-Miller random number generation algorithm. The Miller–Rabin primality test or Rabin–Miller primality test is a primality test: an algorithm which determines whether a given number is prime, similar to the Fermat primality test and the Solovay–Strassen primality test. Here is the source code of the C program to generate random number … Read more

advertisement

C Program to Implement Fisher-Yates Algorithm

This C program implements Fisher-Yates algorithm for array shuffling. 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, known as … Read more

advertisement

C Program to Generate Random Numbers using Multiply with Carry Method

This C program generates random number using multiply with carry method. Most RNGs work by keeping a certain number, say k, of the most recently generated integers, then return the next integer as a function of those k. The initial k integers, the seeds, are assumed to be randomly chosen, usually 32-bits. The period of … Read more

advertisement

C Program to Generate Random Numbers using Middle Square Method

This C program generates random numbers using middle square method. In mathematics, the middle-square method is a method of generating ‘pseudorandom’ numbers.To generate a sequence of 4-digit pseudorandom numbers, a 4-digit starting value is created and squared, producing an 8-digit number (if the result is less than 8 digits, leading zeroes are added to compensate). … 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.