Source Code

Browse practical source code examples in C, C++, Java, JavaScript, PHP, and other programming languages. Learn programming concepts through real-world coding examples, utilities, and software projects.

Solving the Knapsack Problem

Solving the Knapsack Problem with Code Examples

The Knapsack Problem is a classic optimization problem in computer science and mathematics. The goal is to maximize the value of items placed in a knapsack without exceeding its weight capacity. This problem has many variations, but the most common are: 0/1 Knapsack Problem: Each item can either be included or excluded. Fractional Knapsack Problem: Items can be divided to maximize value.

Custom UI Input Elements

Improve User Experience with Custom JavaScript Form Inputs

When we talk about custom form inputs, we are referring to those interactive elements on a web page where users input information. This includes text fields, checkboxes, radio buttons, and dropdown menus. But what makes them “custom”? Unlike standard HTML form elements, custom form inputs are designed and styled to match the specific look and feel of a website or application. They go beyond the default appearance and functionality by offering a unique and tailored user experience.

Binary Decision Diagram (BDD) - Data Structure

Binary Decision Diagram Data Structure

A BDD (Bryant 1986) or branching program is a data structure that is used to represent a Boolean function. On a more abstract level, BDDs can be considered as a compressed representation of sets or relations. Unlike other compressed representations, operations are performed directly on the compressed representation, i.e. without decompression.

php mail function

How to Send Email using PHP

A detailed guide on PHP mail sending options with examples of using the built-in mail function(), PHPMailer, Symfony, and third-party mail service providers such as Amazon SES, SendGrid and GetResponse.

Good Code, Bad Code - Book

Errors: To Fail or To Recover?

The environment in which your code runs is imperfect: users will provide invalid inputs, external systems will go down, and your code and other code around it will often contain some number of bugs. Given this, errors are inevitable; things can and will go wrong, and as a result you can’t write robust and reliable code without thinking carefully about error cases.

Quadratic Formula and Quadratic Equation

C++ Program to Solve the Quadratic Equation

This program will solve quadratic equations. It accepts coefficients of a quadratic equation from the user i.e. a, b and c and displays the roots. To compile the program name it quadratic_solver.cpp then type g++ -o quadratic_solver quadratic_solver.cpp You may need to use math.h like this: #include if you are using windows C++ programming software. (I tried it without the math.h and got an “undeclared identifier” error)

c-algorithms-library

C Algorithms Library

This 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.

Scroll to Top