Algorithm in C - Sanfoundry (original) (raw)

C is a high-level, structured, and procedural programming language that is primarily used in software development. C Algorithm collections contain more than 250 programs, ranging from simple to complex and advanced problems with solutions. These C Algorithms are categorized as string matching, graph, hard graph, topological sorting, cryptography, random algorithms, shortest path, combinatorial, geometric and mathematical algorithms, permutations, combinations, tree, subset, and sieve programs.
This section also covers various C algorithms and implementations of dynamic programming, greedy algorithms, data structures, searching, and sorting algorithms. Every example program on these topics includes a program description, C code, and program output. All examples have been compiled and tested on Windows and Linux systems.
Here is the listing of C Algorithm Topics:
Greedy Algorithms in C
- C Program to Find Minimum Spanning Tree using Kruskal’s Algorithm
- C Program to Find Minimum Spanning Tree using Prim’s Algorithm
- C Program to Solve the Fractional Knapsack Problem
- C Program to Find Shortest Path using Dijkstra’s Algorithm
C Algorithms on Cryptography
- C Program to Implement Affine Cipher
- C Program to Implement the Monoalphabetic Cipher
- C Program to Implement the RSA Algorithm
- C Program to Perform Cryptography using Transposition Technique
- C Program to Implement the Checksum Method for Small String Messages
- C Program to Encrypt Message using Playfair Cipher
Robust Geometric Primitives in C
- C Program to Find Cross Product of Two Vectors
- C Program to Find the Area of a Triangle Using Determinants
- C Program to Find the Volume of a Tetrahedron Using Determinants
- C Program to Use Above Below Primitive to Test Whether Two Lines Intersect
- C Program to Find if a Point Lies Inside or Outside a Circle
- C Program to Apply Above-Below-on Test to Find the Position of a Point with Respect to a Line
Combinatorial Problems in C
- C Program to Find kth Smallest Element in Array using Partitioning
- C Program to Find the Mode of a Data Set
- C Program to Generate All Possible Combinations of List of Numbers
- C Program to Implement Heap’s Algorithm for Generating Permutations
- C Program to Implement Alexander Bogomolny’s UnOrdered Permutation Algorithm
C Algorithms on Subset
- C Program to Generate All Possible Subsets
- C Program to Generate All Possible Subsets using Gray Code Order
- C Program to Generate All Possible Subsets using Lexicographic Order
- C Program to Generate All Possible Subsets using Binary Counting Method
Partition Problems in C
- C Program to Perform Integer Partition for a Specific Case
- C Program to Generate All the Set Partitions of n Numbers Beginning from 1 and so on
- C Program to Generate Random Partition from Given Set
- C Program to Find the Number of Ways to Write a Number as the Sum of Numbers
Numerical Algorithms in C
- C Program to Perform Complex Number Multiplication
- C Program to Optimize Wire Length in Electrical Circuit
- C Program to Perform Optimal Parenthesize using Dynamic Programming
- C Program to Find GCD of Two Numbers Using Recursive Euclid Algorithm
- C Program to Perform the Unique Factorization of a Given Number
- C Program to Implement Booth’s Multiplication Algorithm for Multiplication
- C Program to Implement the Schonhage-Strassen Algorithm for Multiplication
- C Program to Implement the Bin Packing Algorithm
Linear Equations in C
- C Program to Solve any Linear Equation in One Variable
- C Program to Implement Gauss Jordan Elimination
- C Program to Implement Gauss Seidel Method
- C Program to Implement Coppersmith Freivald’s Algorithm
- C Program to Implement Strassen’s Algorithm
Randomized Algorithms in C
- C Program to Generate Random Numbers in a Range
- C Program to use rand() and srand() Functions
- C Program to Generate N Number of Passwords of Length M Each
- C Program to Emulate N Dice Roller
- C Program to Generate Random Hexadecimal Bytes
- C Program to Implement Linear Congruential Method for Generating Pseudo Random Number
- C Program to Generate Random Numbers using Middle Square Method
- C Program to Generate Random Numbers using Multiply with Carry Method
- C Program to Generate Random Numbers using Probability Distribution Function
- C Program to Implement Fisher-Yates Algorithm
- C Program to Implement Park-Miller Random Number Generation Algorithm
- C Program to Implement Naor-Reingold Pseudo Random Function
C Algorithms on Sieve & Primality Test
- C Program to Implement Wheel Sieve to Generate Prime Numbers
- C Program to Implement Sieve of Eratosthenes to Generate Prime Numbers
- C Program to Implement Sieve of Atkin to Generate Prime Numbers
- C Program to Generate Prime Numbers Using Sieve of Sundaram
- C Program to Perform Fermat Primality Test
- C Program to Implement Rabin-Miller Primality Test to Check if a Number is Prime
C Algorithms on Graph
- C Program to Check if Graph is DAG
- C Program to Find Minimum Spanning Tree using Kruskal’s Algorithm
- C Program to Find Minimum Spanning Tree using Prim’s Algorithm
- C Program to Solve Stable Marriage Problem
- C Program to Check Whether a Given Graph is Bipartite or not
- C Program to Generate a Random Subset by Coin Flipping
- C Program to Create a Random Graph Using Random Edge Generation
C Algorithms on Shortest Path
- C Program to Find Shortest Path using Dijkstra’s Algorithm
- C Program to Implement Bellmanford Algorithm
- C Program to Implement Floyd-Warshall Algorithm
- C Program to Find the Transitive Closure of a Graph using Warshall’s Algorithm
- C Program to Implement Johnson’s Algorithm

I’m Manish, Founder & CTO at Sanfoundry, with 25+ years of experience across Linux systems, SAN technologies, advanced C programming, and building large-scale, performance-driven learning and certification platforms focused on clear skill validation.
LinkedIn · YouTube MasterClass · Telegram Classes · Career Guidance & Conversations