Posts

Showing posts from July, 2023

Flight booking system in C++

Image
 Flight booking system using class in C++ The concept of class is best illustrated by using it to build functional systems. A class is a template according to which objects can be created. A class can have data members and member functions. The data members can contain useful information and data specific to an object. A member function can be used for multiple purposes. These purposes include manipulating data members, performing various routines defined by the programmer, etc. Note: The string.h has been used in this program to perform operations on strings. #include <iostream> #include <string.h> //for operations on string using namespace std; How would this system work? credit - https://pixabay.com/users/wal_172619-12138562/   A flight booking system entails the user choosing between different flights based on their preferences (departure location, destination, time, day, etc). A flight class is used to create ...

Greatest common divisor for 2 integers | Algorithm in C++

Image
 Algorithm for finding greatest common divisor of two positive integers Greatest common divisor is the greatest integer which divides both the given positive integers discretely or exactly. I am going to use a version of the Euclid algorithm described in his book Euclid's Elements. The algorithms have been written in the C++ language. The algorithm adapted here used to be one of the most well-known algorithms in the 1950's and one of the first to have the word "algorithm" associated with it. One can find implementations of this algorithm which use recursive functions as well. Here, I have developed a process using the most basic of programming concepts.  This algorithm has a finite number of steps before it terminates( when the remainder becomes zero). It takes in two inputs ("m" and "n") and gives out one output (GCD in the form of "n").  In this example, one can also notice how the do-while loop is better suited to certain situati...