The post Best C++ Program To Find Frequency of A Character in String appeared first on C++ Beginner.

]]>For example, if the given string is **“Hello World!”** and we are asked to find the frequency of character **‘o’** then we can easily find that the specific character occurred **2** times in the given string. Similarly, if someone asks that how many times the character **‘W’** is occurring in the string. We can conclude that** ‘W’** has been occurred only once in the string. So, the frequency of **‘W’** is **1**.

We can do the same thing in C++ programming language easily.

Just think about the logic behind finding the occurrences of a character. Think, how you found the character frequency in the examples stated above.

OK, I tell you. You just read the string carefully and counted the number of occurrences of specific character.

Same thing can be implemented efficiently in C++ program.

Before writing source code, it is good to find the needs of program.

Our program should capable of these two things:

1: Read the String.

2: Count the number of occurrences of specific character.

Now you have logic and probably most of you people can write code on your own. But, for those who cannot write code, I have uploaded source code below for reference.

Don’t leave, I also explained every bit of program code further in this article.

```
#include <iostream>
using namespace std;
int main()
{
string givenStr="Computer Science";
char charToCheck='i';
int count=0;
cout<<"Given String = "<<givenStr;
for (int i=0;i<givenStr.size();i++)
{
if (givenStr[i]==charToCheck)
{
++count;
}
}
cout<<"\n==============================="<<endl;
cout<<charToCheck<<" Occured "<<count<<" Times.";
return 0;
}
```

First of all, we declared a string and initialized it to **“Computer Science”**. We are going to check occurrences of our desired character in this specific string.

We also declared a** char** type variable which contains the character to be checked in the string.

After that, we declared one** int** type variable and it would work as a counter in the program. Initially its value is zero because we don’t have even a single occurrence yet.

Recommended reading: Tower of Hanoi Game Project in C++ With Full Source Code

Next, we started a loop which runs as many times as the number of characters of string found with the help of **size() **function. This loop accesses every single character and compares it to **chartocheck**.

If both characters are same then **count** is increased by one i.e. one more occurrence is detected.

This process is repeated till the end of string. At the end, frequency of specific character is printed on the screen.

One more thing to remember is that A computer distinguishes the characters written in small case and upper case. For example, Computer thinks that **‘a’** is a character and** ‘A’** is some other character.

For example, when we check for** ‘c’** in our given string **“Computer Science”**. It gives us answer 2. In fact, our string contained three occurrences of **‘c’**, 2 times for small letter and one for upper case. But program returned us the occurrences of small case letter because that is what we opted for.

Now, if we check for **‘C’**, we would get 1.

The logic behind this is the ASCII codes for keys. You can learn more about it here.

It is advised to make small changes in code and see what happens.

Now, If you think this article is even a bit useful it is requested to must share the information.

You can also Click Here To Download Exercise Files.

The post Best C++ Program To Find Frequency of A Character in String appeared first on C++ Beginner.

]]>The post Armstrong Number Program in C++ | With Full Explanation & Dry Run appeared first on C++ Beginner.

]]>For example, 153 is a 3-digit Armstrong number because:

**153 = 1 ^{3}+5^{3}+3^{3} = (1*1*1) + (5*5*5) + (3*3*3) = 1+125+27 = 153**

There exists just four 3-digits Armstrong numbers which are 153, 370, 371 and 407.

**1634 **is a perfect example of 4-digit Armstrong number.

**1634 = 1 ^{4}+6^{4}+3^{4}+4^{4} = (1*1*1*1) + (6*6*6*6) + (3*3*3*3) + (4*4*4*4) = 1+1296+81+256 = 1634**

In above example, we raised the digits to the power of 4 because total no. of digits in 1634 is 4.

We should also keep in mind that all single-digit numbers are Armstrong numbers.

Recommended reading: Student Management System Project in C++ Using Linked List

In this section we talk about the logic behind the code and how we construct the program. Let’s break the logic of finding whether a number is Armstrong or not into steps:

- Find the total no. of digits in the number.
- Extract every digit from number.
- Raise each digit to the power of total no. of digits.
- Add the results obtained by raising power.

Now, let’s think how we can convert this logic into a C++ code. In my opinion, this logic can be converted into code like this:

- We can use a loop & counter variable to count the number of digits.
- We can divide the number by 10 to extract digits from integer.
- We need a
**power**function which raises the power by total. No of digits. - We can use a
**sum**variable which adds the result after every multiplication.

```
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int originalnum,digit,tempNum;
int result=0,power=0;
cout<<"Enter A Number: ";
cin>>originalnum;
tempNum=originalnum;
while(tempNum!=0)
{
tempNum=tempNum/10;
power++;
}
tempNum=originalnum;
while(tempNum!=0)
{
digit=tempNum%10;
result=result+pow(digit,power);
tempNum=tempNum/10;
}
if(result==originalnum)
{
cout<<"Armstrong Number.";
}
else
{
cout<<"Not Armstrong Number.";
}
return 0;
}
```

The most important thing about this code is that it contains **math.h** file. It is a header file which contains the functions required to apply mathematical operations. In this program, **pow()** function of this file is used which calculates the power of a number.

First of all, we declared 5 integer type variables to store data. The main purpose of declaring each of them is:

**originalnum**is an integer variable used to save the original number entered by user. We will compare our resultant number with this original number to check whether it is an Armstrong number or not.**tempNum**is a variable used to manipulate the value of original number in whole program. We don’t want to change the value of**originalnum**in whole program, so we used this variable to store the value of original number where we can change it.- We will extract each digit of our original number and store it in
**digit**. **power**is a variable which saves the number by which power of each digit would be raised. Remember that it is the total no. of digits.- We need a temporary storage location to store result of our calculations, so we declared a variable named

After that, we prompted the user to enter the number and store it in **originalnum **variable. We also copied this value in **tempNum **variable.

Recommended reading: C++ Program to Find Size of Any Data Type

Next, we used a **while** loop to count the number of digits present in the entered number. Basically it divides the number by 10 and increments the **power **variable. Dividing by **10** causes decrease of one digit in original number.

Next, we again used **while** loop to find Armstrong number. There are just three statements inside the body of this loop. Let’s see them one by one:

```
digit=tempNum%10;
```

This statement extracts one digit from **tempNum **and stores it in **digit**.

```
result=result+pow(digit,power);
```

This statement raise the digit to the power of total no. of digits and stores thier sum in **result**.

```
tempNum=tempNum/10;
```

This statement divides the number by 10 so one more digit can be accessed by loop.

This loop continues until the resultant number is found.

At the end, we compare obtained number with the original number entered by user. If they become equal then it means that it is an Armstrong number. If they are not equal then it means that entered number is not an Armstrong number.

Next, we entered a 4-digit but it is not an Armstrong number.

Let’s see how this code is executed by the computer. Suppose number entered by user is **153**.

**At start, we have:**

Originalnum=153

tempNum=153

result=0

power=3

**When tempNum=153**

digit=153%10=3

result=0+33=0+27=27

tempNum=153/10=15

**When tempNum=15**

digit=15%10=5

result=27+53=27+125=152

tempNum=15/10=1

**When tempNum=1**

digit=1%10=1

result=152+13=152+1=153

tempNum=1/10=0

This was all about finding an Armstrong number in C++ using** while** loop.

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to ans

You can also Click Here To Download Exercise Files.

The post Armstrong Number Program in C++ | With Full Explanation & Dry Run appeared first on C++ Beginner.

]]>The post C++ Program to Find Sum of Digits of A Number Using Classes appeared first on C++ Beginner.

]]>It is a quite easy job. I will tell you step-by step that how you can manage to find sum of digits of an integer in C++.

**Digit sum** means adding all the digits of a particular number.

For example, if we take a number 532 then its sum of digits will be:

**5+3+2=10**

If we think about the logic behind summation of digits of a number then we can conclude that:

- Take a number from user as input.
- Grab each digit from that number.
- Add all the digits grabbed from number.
- Display the
**sum**on screen.

**One question arises that how we will extract the digits from given number?**

The answer to this question is very simple. Dividing a number by 10 gives us the last digit of that number as remainder. We will continue a loop to grab each digit of the number and sum them up.

Recommended reading: C++ Program For Addition of Two Numbers Using Classes

```
#include<iostream>
using namespace std;
class SUMdigits
{
private:
int num,sum;
public:
SUMdigits()
{
num=sum=0;
}
void input()
{
cout<<"ENTER NUMBER: ";
cin>>num;
}
void sum_Function()
{
while(num>0)
{
int rem;
rem=num%10;
sum=sum+rem;
num=num/10;
}
}
void output()
{
cout<<"SUM OF DIGITS: "<<sum;
}
};
int main()
{
SUMdigits obj;
obj.input();
obj.sum_Function();
obj.output();
return 0;
}
```

This program is based on the concepts of Object Oriented Programming (OOP). As data members, classes, member functions are used in this program to accomplish the task.

First of all, we defined a new class named **SUMdigits **and included two data members i.e. variables named **num **&** sum**.

We also defined a constructor which initializes the values of both variables to zero.

Next, we declared a function to get input from user. We asked the user to enter a number and stored it in **num** variable.

After that, we defined a function named** digits_Sum **i.e. main part of this class. This function extracts all the digits from number and sum them.

Here, we declared **rem** variable to store the remainder of division.

We initialized a loop which continues until **num ** is greater than 0. It means that loop will stop if there is no more digit in given number.

Recommended reading: C++ Project For Address Book Management

I have told you before that dividing a number by 10 gives us the last digit of that number as remainder. It means that one digit is extracted from number and we stored that digit in **rem** variable.

Next, we added this number to **sum** variable which is the result of this program.

At the end, we used **output()** function to show the sum of digits on screen.

In **main** function, we simple declared an object and used all three functions of **SUMdigits** class.

If you want to learn about finding sum of digits of number without classes then you can __Read Here__.

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Exercise Files.

The post C++ Program to Find Sum of Digits of A Number Using Classes appeared first on C++ Beginner.

]]>The post Calculating The Size of Any Data Type in C++ Using sizeof Operator appeared first on C++ Beginner.

]]>You can use this operator to calculate size of any data type like **int**, **float**, **char **and etc.

The syntax of using **sizeof** operator is as follows:

```
sizeof(data type);
```

Where data type includes constants, variables, classes, structures, unions or any other user defined data type.

**sizeof** cannot be used with function types or incomplete types etc.

Recommended reading: C++ Program to Find Quotient and Remainder

//This code was uploaded on www.cppbeginner.com #include<iostream> using namespace std; int main() { cout<<"Size of Character: "<<sizeof(char)<<" Byte"<<endl; cout<<"Size of Integer: "<<sizeof(int)<<" Bytes"<<endl; cout<<"Size of Float: "<<sizeof(float)<<" Bytes"<<endl; cout<<"Size of Double: "<<sizeof(double)<<" Bytes"<<endl; return 0; }

First of all, we used **cout** statement to show appropriate messages on the screen.

After that we used **sizeof **operator to calculate the size of data types.

At first, we used data type “**char**”. At the end, we again used **cout** to print the sizes of data types on screen. Program told us that it takes 1 byte of memory which is true.

For another example, we placed “**int**” in the parenthesis and program showed that it takes 4 bytes memory.

You can also use this program to find size of other data types like **long**, **short** and etc.

Recommended reading: Student Management System Project in C++

This was all about finding the size of any data type in C++ programming language.

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Project Files.

The post Calculating The Size of Any Data Type in C++ Using sizeof Operator appeared first on C++ Beginner.

]]>The post C++ Program to Find Quotient and Remainder of Two Integers Entered By User appeared first on C++ Beginner.

]]>First we need to become familiar with some basic terminologies of division operation.

- The number which is being divided is called
**dividend**. - The number by which we divide is called
**divisor**. - The result of division is called
**quotient**. - The number left over is called
**remainder**.

In this C++ program, first we want to find the quotient of two numbers. The quotient of two numbers is calculated by dividing the dividend by divisor. So, the formula for quotient is:

**Quotient = Dividend / Divisor**

The next part of our program is based on the question, How to find remainder in C++?

The remainder is calculated by using mod( % ) operator between two operands. So, the formula for remainder is:

**Remainder = Dividend % Divisor**

Now, we have the all the necessary formulas and we can use them to build a C++ program to find quotient and remainder of two numbers entered by user.

Recommended reading: How to add two numbers using classes in C++

```
#include<iostream>
using namespace std;
int main()
{
int quotient,remainder;
int divisor,dividend;
cout<<"ENTER DIVIDEND:";
cin>>dividend;
cout<<"ENTER DIVISOR:";
cin>>divisor;
quotient=dividend/divisor;
remainder=dividend%divisor;
cout<<"QUOTIENT="<<quotient<<endl;
cout<<"REMAINDER="<<remainder;
return 0;
}
```

First of all, we declared 4 variables named **dividend**,** divisor**,** quotient **& **remainder**. All these variables are of integer data type. We cannot declare them as **float ** because modulus ( % ) operator can never be applied on floating-type variables.

After that, we simply asked the user to enter the values of **dividend **and **divider**. We applied division operation on provided values and found the value of **quotient**. Next, we applied mod( % ) operator on provided values and found **remainder** of division.

Recommended reading: Convert Years of Age into Months, Days, Hours And Minutes in C++

At the end, we simply printed the values of **quotient **and **remainder** on the screen.

Let’s dry run this code to see how it works:

Suppose **48** and **5** are hypothetical values of **dividend** and **divisor **respectively.

Quotient = Dividend / Divisor = 48 / 5 =9

Remainder = Dividend / Divisor = 48 % 5 = 3

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Project Files.

The post C++ Program to Find Quotient and Remainder of Two Integers Entered By User appeared first on C++ Beginner.

]]>The post C++ Program to Convert Years of Age into Months, Days, Hours And Minutes appeared first on C++ Beginner.

]]>There are some formulas which are used to convert time of one format into another:

To convert years of age into months, we just need one information i.e. number of years. So we will make a function which takes just no. of years as input and converts it into another time standard. We also know that one year contains twelve months in it. So, we will multiply no. of years with 12 to get actual number of months.

A common year has 365 days. Leap year has an additional day i.e. 366 days. For the sake of simplicity of the program, we will take one year as 365 days. If you want to get more accurate result then you can use **Days = Years * 365**.

It is obvious that one day has 24 hours. We have calculated no. of days in above formula. So multiplying this number with 24 can give us accurate number of hours in the age.

Collectively 60 minutes make one complete hour. To get no. of minutes, we will have to multiply the no. of hours with 60.

Recommended reading: How to Check Whether A Number is Prime Or Not in C++

```
#include<iostream>
using namespace std;
int main()
{
int years,months,days,hours,minutes;
cout<<"ENTER AGE IN YEARS = ";
cin>>years;
months=years*12;
days=years*365;
hours=days*24;
minutes=hours*60;
cout<<"\nAGE IN MONTHS = "<<months<<endl;
cout<<"AGE IN DAYS = "<<days<<endl;
cout<<"AGE IN HOURS = "<<hours<<endl;
cout<<"AGE IN MINUTES = "<<minutes;
return 0;
}
```

First of all we declared five variables to store values in different time standards. All the variable are of **int **data type. After that we used formulas to do calculations and stored values in the corresponding variables. At the end, we printed the results on screen.

Recommended reading: How to Find Grade of a Student in C++

Let’s dry run this code by giving it a hypothetical value **14**.

Years=**14**

Months = Years * 12 =14 * 12 = **168**

Days = Years * 365 = 14 * 365 = **5110**

Hours = Days * 24 = 5110 * 24 = **122640**

Minutes = Hours * 60 = **7358400**

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Exercise Files.

The post C++ Program to Convert Years of Age into Months, Days, Hours And Minutes appeared first on C++ Beginner.

]]>The post Address Book Project in C++ with Source Code appeared first on C++ Beginner.

]]>Developed Under: **Dev C++ 5.11**

Data Structure: **Linked List**

Object Oriented Programming: **Yes**

An address book is used to maintain the records of your acquaintances. This project is an electronic way of storing your contacts. User can use this program to store his contacts, search through them and make a list of special friends.

This contact book program uses **Linked List** to store information of contacts. If you don’t know about Linked List then you can __Read Here.__

Students are advised to completely study the code of this program before copying it into their systems. By reading the code of project, they can make many projects on their own. This is the real purpose behind sharing of this project.

The main functions of this program are:

- A user can enter record of new acquaintances.
- User can delete the a record from list.
- User can view the list of all contacts.
- User can search through all the contacts.
- User can make a list of special friends.

Recommended reading: Student Management System Project Using Binary Search Tree

The main features of this program are:

A user can make a list of his favorite people. This feature allows the user to insert a contact in this list, delete a contact from this list and see all the contacts present in the list. This list is very necessary when we have a large number of contacts in the book. We put our mostly used contacts in **Favorites** list and access them quickly.

The main advantage of this program is that it uses **Linked List** instead of array to store data. In array, insertion and deletion become time consuming because these operations require data movement. Also the size of array is fixed during execution, new items can be added only if there is room. These limitations of array are overcomed by **Linked list**. Pointers are used to organize and process data in **Linked List. **In Linked List, memory can be dynamically allocated and released using pointers.

In this program, One node of **Linked List ** contains the **next** pointer and all the variables to store data of a single contact like name, address, phone number etc.

This program is based on the concepts of OOP in C++. OOP stands for Object Oriented Programming. This program has basic building blocks of OOP like classes, constructors, member functions etc which make this program flexible and secure.

Recommended reading: Airline Ticket Reservation System in C++

Data validation is the process of ensuring that a program operates on correct data. This program is packed with some functions that prohibits the user to input wrong data.

The interface of this program is introduced with different color schemes. You can see from screenshots that different colors are assigned to different sections of program. Also, borders are added around the data which make the program beautiful.

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Project Files.

The post Address Book Project in C++ with Source Code appeared first on C++ Beginner.

]]>The post C++ Project | Student Management System using Linked List appeared first on C++ Beginner.

]]>Project Title: **Student Management System Project in C++**

Developed Under: **Dev C++ 5.11**

Data Structure: **Linked List**

Object Oriented Programming: **Yes**

This C++ project is developed to manage the record of students in a school. This project stores the information of students and displays them to the user. It also allows to search, edit or delete a student from list.

This project is not another array-based program. Rather, It is developed using** Linked List **data structure. To learn more about Linked list, __Click Here.__

You can download the source code of this C++ Student Management System by clicking on the link given above.

The main purpose of uploading the projects on this website is that students can get better understanding of syntax and functions using projects.

Recommended reading: C++ Project | Airline Ticket Reservation System Project

The main functions of this project are:

- A user can add records of students in the program.
- User can delete a specific student from list.
- Program can display the record of all students.
- User can search through all records.
- User can edit a specific record.

The main features of this program are:

OOP stands for Object Oriented Programming. This program has basic building blocks of OOP like classes, constructors, member functions etc. In fact, programs written using OOP contains much more flexibility and security than other programs.

This program uses pointers to organize and process data in list, called **Linked List**. In Linked List, memory can be dynamically allocated and released using pointers. The main advntage of this program is that it uses **Linked List** instead of array to store data. In array, insertion and deletion become time consuming because these operations require data movement. Also the size of array is fixed during execution, new items can be added only if there is room. These limitations of array are avoided using Linked list.

The interface of this program is blended with some eye-catching graphics. These graphics make the interface of program beautiful.

Recommended reading: C++ Game Project | Tower Of Hanoi Using Stacks

For every management system, data validation is absolutely necessary. This project comes with function that validates data. For example, a function stops the user to enter integers in a string which was declared to store the name of student.

This was all about student management system project in C++.

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Project Files.

The post C++ Project | Student Management System using Linked List appeared first on C++ Beginner.

]]>The post Student Management System Project in C++ appeared first on C++ Beginner.

]]>Developed Under: **Dev C++ 5.11**

Data Structure: **Binary Search T****ree**

Object Oriented Programming: **Yes**

The use of computer is emerging in every field of life. Nearly a computer simulation of every physical phenomena is prepared. In the past, it was hard to keep the record of students. Now a days, computer programs are developed which stores the records and processes them efficiently.

This project is also one of them and it is developed in C++ programming language.

The special thing about this Student Management System Project is that it uses **Binary Search Tree (BST) **data structure. You can read more about this data structure by Clicking Here.

The main functions of this project are:

- A user can add records of students in the program.
- User can delete a specific student from data set.
- Program can display the record of all students in two ways i.e ascending & descending.
- User can search through all records.
- User can find the depth of node on which record is present.

To download the C++ code of Student Management System, Click on the link given above.

Recommended reading: Airline Ticket Reservation System Project in C++

The main purpose of uploading the projects on this website is that students can get knowledge from it.

The main features of this program are:

This program has a login system which asks the user to enter **Username** and **Password**.If the login credentials entered by user are incorrect the he will not be able to access the program. The default values required to login are:

Usernme = ammar

Password = 12345

A time calculating function is included in this program. This function calculates the current time and date and prints it on the screen.

Program can show data in both ascending and descending order for the ease of access. Now it takes the **roll number** as a key and sorts data around it. You can also change it to **CGPA**.

BST stands for Binary Search Tree. The main reason behind using this data structure is **fast access**. When data is being organized, a programmer’s highest priority is to organize it in such a way that item insertion, deletion, and lookups (searches) are fast. For example, If we want to find a specific student in an unsorted array then we have to traverse the whole array which is very time consuming. We can use **BST** which reduces the access time for a specific record. The time complexity of BST is O(log_{2}n).

Recommended reading: C++ Game Project | Tower Of Hanoi Using Stacks

This program also tells the total number of students present in the list. Basically one node of BST contains the record of one student. So, this program counts the total no. of nodes which is also the total no. of students. Program also tells the depth of a specific node.

The interface of this student management system program is designed using good sense of background and foreground color.

Originally this program is written by my friend, Ammar Ahmed. He is a tech geek who loves to write about technology and programming. He is studying Computer Science in University of Gujrat. He shared this project to help other students. This School Mangement System project is one of best projects made by him.

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Project Files.

The post Student Management System Project in C++ appeared first on C++ Beginner.

]]>The post C++ Game Project | Tower Of Hanoi Using Stacks appeared first on C++ Beginner.

]]>Developed Under: **Dev C++ 5.11
**

Data Structure: **Stack**

Object Oriented Programming: **Yes**

The Tower of Hanoi is a mathematical puzzle game. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.The objective of the puzzle is to move the entire stack to another rod.

There are some rules which should be obeyed playing the game:

- Only one disk can be moved among the towers at any given time.
- A disk can only be moved if it is the uppermost disk on a stack.
- No large disk can sit over a small disk.

Tower of Hanoi puzzle with n disks can be solved in minimum of 2^{n}−1 steps. A puzzle with 3 disks takes minimum of 2^{3} – 1 = 7 steps.

Recommended reading: Airline Ticket Reservation System Project in C++

To download the C++ code of tower of hanoi, Click on the link given above.

The basic purpose of uploading the code on this website is that students can get knowledge from it. It helps them in understanding the syntax, functions of the programming language.

The main features of this C++ program are:

This game has 2 levels. Level1 contains 3 disks while level2 contains 4 disks. If you are an expert in level1 then you can move onto level 2 which is a bit difficult.

A user guide is included in the program which tells the user about the rules of game. A programmer is also recommended to read these rules before analyzing the code of program. A user can access these rules by pressing “**1**” in main menu.

Like all other games, this game also has a scoring system which computes the score based on the moves. If a person moves the disk many times to complete the puzzle then his score will get worse.

Recommended reading: Static Functions: Access Member Function Without Object in C++

This program uses the **stack** data structure. This data structure is based on **LIFO ** i.e Last In First Out principle. For example, if you want to get the computer science book, which is underneath your math and history books, you must first remove the math and history books to access the desired book. You can consider the 3 rods of this program as 3 stacks.

File handling is a crucial part in a program. This program uses file handling to store the scores. C++ code creates a **.dat ** file and stores “best scores” in it.

Originally this program is written by my friend, Abu Bakar Ghori. He has a lot of interest in programming. He is studying Computer Science in University of Gujrat. He shared this project to help other students. This project is one of best projects made by him. I hope so that he will write more programs to upload on this website.

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Project Files.

The post C++ Game Project | Tower Of Hanoi Using Stacks appeared first on C++ Beginner.

]]>