codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
⚡

C++ Programming

84 / 87 topics
84Projects & Programming Examples85Exercises, Quizzes & Code Challenges86Interview Questions87Learning Paths, Syllabus & Certification
Tutorials/C++ Programming/Projects & Programming Examples
⚡C++ Programming

Projects & Programming Examples

Updated 2026-05-12
30 min read

Projects & Programming Examples

In this section, we dive into several C++ projects that will help you apply what you've learned so far. These examples range from simple utilities like calculators and file encryption to more complex systems such as student management and banking applications. Each project is designed to reinforce key concepts while introducing new ones.

Calculator

A basic calculator can perform arithmetic operations like addition, subtraction, multiplication, and division. This example will guide you through creating a simple console-based calculator.

Code Example

calculator.cpp
1#include <iostream>
2
3using namespace std;
4
5int main() {
6 char op;
7 float num1, num2;
8
9 cout << "Enter operator either + or - or * or /: ";
10 cin >> op;
11
12 cout << "Enter two operands: ";
13 cin >> num1 >> num2;
14
15 switch(op) {
16 case '+':
17 cout << num1 << " + " << num2 << " = " << num1 + num2;
18 break;
19
20 case '-':
21 cout << num1 << " - " << num2 << " = " << num1 - num2;
22 break;
23
24 case '*':
25 cout << num1 << " * " << num2 << " = " << num1 * num2;
26 break;
27
28 case '/':
29 if(num2 != 0.0)
30 cout << num1 << " / " << num2 << " = " << num1 / num2;
31 else
32 cout << "Error! Division by zero is not allowed.";
33 break;
34
35 default:
36 // operator doesn't match any case constant (+, -, *, /)
37 cout << "Error! operator is not correct";
38 break;
39 }
40
41 return 0;
42}

Expected Output

Output
Enter operator either + or - or * or /: +
Enter two operands: 5.2 4.8
5.2 + 4.8 = 10

Student Management System

A student management system can help manage student records, including adding, updating, and displaying student information.

Code Example

student_management.cpp
1#include <iostream>
2#include <string>
3
4using namespace std;
5
6class Student {
7public:
8 string name;
9 int age;
10 float gpa;
11
12 void display() {
13 cout << "Name: " << name << endl;
14 cout << "Age: " << age << endl;
15 cout << "GPA: " << gpa << endl;
16 }
17};
18
19int main() {
20 Student students[3];
21
22 for(int i = 0; i < 3; i++) {
23 cout << "Enter details of student " << i+1 << ":" << endl;
24 cout << "Name: ";
25 cin >> students[i].name;
26 cout << "Age: ";
27 cin >> students[i].age;
28 cout << "GPA: ";
29 cin >> students[i].gpa;
30 }
31
32 cout << "
33Student Details:" << endl;
34 for(int i = 0; i < 3; i++) {
35 students[i].display();
36 }
37
38 return 0;
39}

Expected Output

Output
Enter details of student 1:
Name: Alice
Age: 20
GPA: 3.5
Enter details of student 2:
Name: Bob
Age: 22
GPA: 3.8
Enter details of student 3:
Name: Charlie
Age: 19
GPA: 3.7

Student Details:
Name: Alice
Age: 20
GPA: 3.5
Name: Bob
Age: 22
GPA: 3.8
Name: Charlie
Age: 19
GPA: 3.7

Tic-Tac-Toe

Tic-tac-toe is a classic two-player game where players take turns marking spaces in a 3x3 grid with X or O, trying to get three of their marks in a row.

Code Example

tic_tac_toe.cpp
1#include <iostream>
2using namespace std;
3
4char board[3][3] = {{' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '}};
5
6void displayBoard() {
7 cout << "-------------" << endl;
8 for (int i = 0; i < 3; i++) {
9 cout << "| ";
10 for (int j = 0; j < 3; j++)
11 cout << board[i][j] << " | ";
12 cout << endl;
13 cout << "-------------" << endl;
14 }
15}
16
17bool checkWin(char player) {
18 // Check rows, columns and diagonals
19 for(int i=0; i<3; i++) {
20 if(board[i][0]==player && board[i][1]==player && board[i][2]==player)
21 return true;
22 if(board[0][i]==player && board[1][i]==player && board[2][i]==player)
23 return true;
24 }
25 if(board[0][0]==player && board[1][1]==player && board[2][2]==player)
26 return true;
27 if(board[0][2]==player && board[1][1]==player && board[2][0]==player)
28 return true;
29
30 return false;
31}
32
33int main() {
34 char currentPlayer = 'X';
35 bool gameWon = false;
36 int row, col;
37
38 while(!gameWon) {
39 displayBoard();
40 cout << "Player " << currentPlayer << ", enter your move (row and column): ";
41 cin >> row >> col;
42
43 if(row >= 0 && row < 3 && col >= 0 && col < 3 && board[row][col] == ' ') {
44 board[row][col] = currentPlayer;
45 gameWon = checkWin(currentPlayer);
46 if(gameWon) {
47 displayBoard();
48 cout << "Congratulations! Player " << currentPlayer << " wins!" << endl;
49 }
50 else {
51 // Switch player
52 currentPlayer = (currentPlayer == 'X') ? 'O' : 'X';
53 }
54 }
55 else {
56 cout << "Invalid move. Try again." << endl;
57 }
58 }
59
60 return 0;
61}

Expected Output

Output
-------------
|   |   |   |
-------------
|   | X |   |
-------------
|   |   |   |
-------------
Player O, enter your move (row and column): 1 1
-------------
|   | O |   |
-------------
|   | X |   |
-------------
|   |   |   |
-------------
Congratulations! Player X wins!

Banking System

A banking system can handle basic operations like creating accounts, depositing money, withdrawing money, and displaying account details.

Code Example

banking_system.cpp
1#include <iostream>
2#include <string>
3using namespace std;
4
5class Account {
6public:
7 string name;
8 int accNo;
9 float balance;
10
11 void display() {
12 cout << "Account Holder: " << name << endl;
13 cout << "Account Number: " << accNo << endl;
14 cout << "Balance: $" << balance << endl;
15 }
16
17 void deposit(float amount) {
18 balance += amount;
19 cout << "$" << amount << " deposited successfully." << endl;
20 }
21
22 bool withdraw(float amount) {
23 if(amount > balance) {
24 cout << "Insufficient balance!" << endl;
25 return false;
26 }
27 balance -= amount;
28 cout << "$" << amount << " withdrawn successfully." << endl;
29 return true;
30 }
31};
32
33int main() {
34 Account accounts[2];
35
36 for(int i = 0; i < 2; i++) {
37 cout << "Enter details of account " << i+1 << ":" << endl;
38 cout << "Name: ";
39 cin >> accounts[i].name;
40 cout << "Account Number: ";
41 cin >> accounts[i].accNo;
42 cout << "Initial Balance: $";
43 cin >> accounts[i].balance;
44 }
45
46 int choice, accNo, amount;
47 while(true) {
48 cout << "
491. Deposit
502. Withdraw
513. Display Account Details
524. Exit" << endl;
53 cout << "Enter your choice: ";
54 cin >> choice;
55
56 if(choice == 4)
57 break;
58
59 cout << "Enter account number: ";
60 cin >> accNo;
61
62 for(int i = 0; i < 2; i++) {
63 if(accounts[i].accNo == accNo) {
64 switch(choice) {
65 case 1:
66 cout << "Enter amount to deposit: $";
67 cin >> amount;
68 accounts[i].deposit(amount);
69 break;
70 case 2:
71 cout << "Enter amount to withdraw: $";
72 cin >> amount;
73 accounts[i].withdraw(amount);
74 break;
75 case 3:
76 accounts[i].display();
77 break;
78 }
79 break;
80 }
81 }
82 }
83
84 return 0;
85}

Expected Output

Output
Enter details of account 1:
Name: John
Account Number: 123456
Initial Balance: $500

Enter details of account 2:
Name: Jane
Account Number: 654321
Initial Balance: $1000

1. Deposit
2. Withdraw
3. Display Account Details
4. Exit
Enter your choice: 1
Enter account number: 123456
Enter amount to deposit: $200
$200 deposited successfully.

1. Deposit
2. Withdraw
3. Display Account Details
4. Exit
Enter your choice: 3
Enter account number: 123456

Account Holder: John
Account Number: 123456
Balance: $700

File Encryption

File encryption involves converting the contents of a file into an encoded format to protect sensitive information.

Code Example

file_encryption.cpp
1#include <iostream>
2#include <fstream>
3using namespace std;
4
5void encryptFile(string inputFile, string outputFile) {
6 ifstream fin(inputFile);
7 ofstream fout(outputFile);
8
9 char ch;
10 while(fin.get(ch)) {
11 fout.put(ch + 1); // Simple encryption by shifting each character by 1
12 }
13
14 fin.close();
15 fout.close();
16}
17
18int main() {
19 string inputFile, outputFile;
20
21 cout << "Enter input file name: ";
22 cin >> inputFile;
23 cout << "Enter output file name: ";
24 cin >> outputFile;
25
26 encryptFile(inputFile, outputFile);
27
28 cout << "Encryption completed successfully." << endl;
29
30 return 0;
31}

Expected Output

Output
Enter input file name: example.txt
Enter output file name: encrypted.txt
Encryption completed successfully.

Summary

ConceptDescription
CalculatorSimple arithmetic operations using switch statements.
Student Management SystemManaging student records with classes and objects.
Tic-Tac-ToeImplementing a classic game logic with functions and arrays.
Banking SystemHandling bank account operations like deposit, withdraw, and display details.
File EncryptionBasic file encryption using character shifting for demonstration purposes.

What's Next?

Congratulations on completing these projects! You've now gained hands-on experience with various C++ applications. The next step is to test your skills through exercises, quizzes, and code challenges. These will further reinforce your understanding and prepare you for more advanced topics in programming.

Move on to the Exercises, Quizzes & Code Challenges section to continue practicing and improving your C++ proficiency.


Previous<algorithm> ReferenceNext Exercises, Quizzes & Code Challenges

Recommended Gear

<algorithm> ReferenceExercises, Quizzes & Code Challenges