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)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.2 (57)
Calandar generator printing a full calendar for any yearJoe C++ANSI5.2 (70)
Shorter version of gotoxyNedeljko CLinux5.1 (59)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI4.6 (65)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.3 (50)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple4.1 (43)
Function pointer to member function of classselvam C++ANSI4.0 (39)
Generate a spiral matrix for n elementsRaza C or C++ANSI3.9 (49)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI3.9 (45)
string to bitstring, bitstring to stringEsa Karjalainen CANSI3.9 (43)
An example use of a function pointerJayesh C++ANSI3.3 (40)
Find the minimum distance between two linesGiacomo C or C++ANSI2.9 (35)
This C code assigns codes to a maximum of 10 charsAbhishek H.Dwivedi C or C++Windows2.9 (33)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows2.5 (31)
Previous 30

Add a snippet!