C and C++ Source Code Snippets

Welcome to Cprogramming.com's programming code snippet repository. Peruse the archives or add your own snippets for others to use! (Check the following link a better definition of a snippet)

Sort by clicking on any of the headers.

SnippetAuthorLanguagePlatformRating (votes)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI4.9 (101)
Simple swapping heapsortyzb3 C or C++ANSI5.7 (124)
Templated queue classAli Nawkhas Murad C++ANSI5.4 (112)
Example of polymorphismAli Nawkhas Murad C++ANSI5.4 (172)
Templated stack class Ali Nawkhas Murad C++ANSI5.1 (101)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.3 (106)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.3 (235)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.2 (57)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI3.9 (45)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI4.8 (96)
ASCII table generatorAbdul Haseeb Mir C++ANSI4.8 (105)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.1 (106)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.5 (87)
binary addition using stack in STLanmol C++ANSI4.9 (96)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI4.7 (145)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.5 (132)
Useful string functionsyzb3 CANSI5.4 (132)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.2 (116)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI5.0 (114)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.6 (144)
The standard ASCII table generator.Ali Nawkhas Murad C++ANSI5.0 (100)
friend function exampleAli Nawkhas Murad C++ANSI4.7 (66)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
A code template for OpenGL / GLUTPerspective C or C++ANSI5.7 (255)
Permutation GeneratorTreenef C++ANSI5.7 (456)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.2 (162)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
a simple clockrichmond caesar CANSI5.5 (537)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (369)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
Next 30
Previous 30

Add a snippet!