Tag: C++ Programming

Bubble Sort C Program

Bubble Sort is the most simple form of sorting algorithm that works by repeatedly stepping through the list of items (array) and swapping the adjacent elements if they are in incorrect order. This algorithm has no such real life uses due to it’s poor performance and is used primarily as an educational tool.

Read More

Multiplication of Two Matrices in C

This C code multiplies two 2×2 matrices. It prompts the user to input values for both matrices, displays the input matrices, performs matrix multiplication using nested loops, and then prints the resulting matrix. The code adheres to modern C standards, using printf and scanf for I/O and avoiding outdated functions for better readability and compatibility.

Read More

Defensive Programming Techniques

This source code is from Thinking in C++, 2nd Edition, Volume 2, by Bruce Eckel & Chuck Allison. You can use Borland, G++ (For version 3 and above only), Microsoft (For C++ with .NET only) to compile and build this source code. Writing perfect software may be a daunting task for developers, but a few defensive techniques which are routinely applied can go a long way toward narrowing the gap between code and ideal. Defensive programming practices are often used where high availability of the application is required, safety if utmost concern, or security is needed for application to work.

Read More

Object Oriented Programming (OOP)

For a programming language to be considered Object-Oriented, it must support the concept of objects (abstract data types), inheritance, and polymorphism. In simple terms, OOP allows you to model your code after real-world entities, making it more intuitive and efficient. As you delve into C++ and its OOP features, keep in mind that the goal is to create programs that are not only functional but also easy to understand, maintain, and reuse.

Read More