The best way to learn any programming language is by practicing examples. This source code section features a diverse collection of programming examples and source code snippets written C, C++ and other programming languages.
The examples includes practical implementations, tutorials, and demonstrations aimed at helping programmers enhance to enhance their programming skills.
Table of Contents
- C Programming Source Code
- C++ Programming Source Code
- PHP Code Snippets
- Java Source Code
C Programming Source Code
- LRU and FIFO L1 Cache Implementation using CThis is a C program to demonstrate cache mechanism by simulating a cache in C. The source code can run in any C Compiler with minor modifications if required. It can run on real memory traces as input to your cache simulator. We have implemented two cache replacement policies i.e. least recently used (LRU) and First-in first-out (FIFO) replacement policies.
- Random Number Generation in C/C++: Tricks for Generating, Seeding, and Working with Random NumbersC Standard Library provides two different methods to generate random numbers. They are: rand() and srand().
- C Algorithms LibraryThis article is about a collection of common Computer Science algorithms which may be used in C projects. The C Programming Language has a much smaller Standard Library as compared to other more modern programming languages such as Java or Python. The library provides a basic set of mathematical functions, string manipulation, type conversions, and file and console-based I/O.
C++ Programming Source Code
- Rock, Paper, Scissors Game in C++ [C++ Game]This is a simple C++ program to demonstrate rock, paper, scissors game. In this game, players have to choose one of the three options to beat the opponent or the computer itself. The C++ code generates a random choice by creating a character to indicate that option. Options are: r is for ‘rock’, p is for ‘paper’, and s is for ‘scissors’.
- C++ Code – Wave File Converter from Text FileThis C++ program is capable of turning a text file describing the notes of a piece of music into an audio file (.wav). The program reads the contents of the input file i.e. input.txt, constructs Song, Voice and Note objects describing the notes in the file, and call the different… Read more: C++ Code – Wave File Converter from Text File
- Vigenere Encryption and Decryption in C++The Vigenere cipher is a method of encrypting or decrypting alphabetic text by using a series of interwoven Caesar ciphers (Caesar Shift), based on the letters of a keyword. In cryptography, Caesar shift is one of the simplest known encryption techniques. It employs a form of polyalphabetic substitution, which is using multiple substitution alphabets.
PHP Code Snippets
- Send Email using PHPIn this article we present a sample source code to send email using the PHP programming language. The default mail() function of PHP has the following parameters and returns a boolean value to show whether the mail() function was successful or not. We use error_get_last() function to get the last… Read more: Send Email using PHP
- Search the LDAP Directory in PHPThis PHP code connects to an LDAP server, performs a search for entries with the last name and then sorts and prints them alphabetically. The sorting is done by a custom function called compareEntry, which compares entries based on last names and first names. It uses the LDAP functions to communicate with the server and showcases basic error handling.
- Calculating the Greatest Common Denominator (GCD) in PHPThis PHP code defines a function called gcd that calculates the greatest common denominator (GCD) of a list of integers by using a brute-force approach and later efficient and widely-used method called Euclidean Algorithm.
Java Source Code
- Java Program to demonstrate of Linked ListThis is a very simple implementation of linked list in java programming language. Very nice and well commented java source code for beginners.
- Java Program to Show Stack ImplementationThis is a simple Java program to demonstrate the Stack data structure implementation. This code provides a simple implementation of a stack with basic operations (push, pop, and isEmpty).
- Stack Implementation with ArrayThis java code implements stack functionality by using arrays. It can Pop and Push an item in stack with the help of array. The item can only be an integer number and internally the java program uses arrays to maintain items in stack.