MICROPROJECT REPORT
Tic Tac Toe Game Using C Language
Subject: Programming in C
Academic Year: 2024–2025
Submitted by:
• Purvesh Nitin Jadhav
• [Member 2 Name]
• [Member 3 Name]
• [Member 4 Name]
Class: FYIT – Information Technology
Institute: Government Polytechnic Awasari
CERTIFICATE
This is to certify that Mr. Purvesh Nitin Jadhav and team members [Member 2 Name],
[Member 3 Name], and [Member 4 Name] of First Year Diploma in Information
Technology, Government Polytechnic Awasari, have successfully completed the
microproject titled “Tic Tac Toe Game Using C Language” under the subject
Programming in C. This project has been carried out as part of the academic requirements
for the academic year 2024–2025, and the contents of this report represent original work
executed under my guidance and supervision.
Date: ___________
Guide’s Signature: _____________________
HOD’s Signature: ______________________
ACKNOWLEDGEMENT
We would like to express our heartfelt gratitude to our subject teacher [Teacher’s Name],
who provided us with invaluable guidance, continuous support, and motivation
throughout the course of this microproject. Their expert advice and enthusiasm greatly
contributed to the successful completion of this project.
We would also like to thank the Head of Department and the faculty of the Information
Technology Department for their encouragement and for providing us the resources and
environment to work productively.
We are deeply grateful to each other for the great teamwork and cooperation shown
during this microproject.
Finally, we thank our families for their support and motivation which helped us complete
this work with dedication and passion.
— Purvesh Nitin Jadhav & Team
INDEX
Sr. No. Content Page No.
1 Introduction
2 Objective
3 Tools and Technologies
Used
4 Problem Statement
5 System Design and Game
Logic
6 Algorithm and Explanation
7 Source Code
8 Output Screens
9 Applications and Real-
world Benefits
10 Learning Outcomes
11 Conclusion
12 References
Introduction
The Tic Tac Toe game is a two-player game that has stood the test of time due to its
simplicity, competitiveness, and strategic nature. It is commonly played on a 3x3 grid,
where each player alternates marking spaces with either X or O. The game ends when a
player places three of their marks in a horizontal, vertical, or diagonal row, or when all
cells are filled with no winner. This project involves building a C program that simulates
the same game in a text-based environment. The project helps us understand control flow,
conditional logic, and efficient program design using C programming.
Objective
The primary objective of this microproject is to design and develop a working console-
based application of the Tic Tac Toe game using the C programming language. Through
this project, we aim to apply the concepts of control structures, user input handling,
conditionals, and loops. It also focuses on enhancing logical thinking and problem-
solving ability among students by converting a real-world game into its virtual version.
Tools and Technologies Used
• Programming Language: C
• Text Editor: Code::Blocks, Turbo C++
• Compiler: GCC
• Platform: Windows/Linux
• Skills: Logic development, input validation, game development basics
Problem Statement
To develop a user-friendly text-based game using C programming where two users can
play the Tic Tac Toe game. The game should be able to identify invalid inputs, alternate
turns, and detect win or draw conditions efficiently. It should simulate a real Tic Tac Toe
board and display the game status after every turn.
System Design and Game Logic
The game is designed using basic variables to represent the 3x3 board. Each box is filled
with a number from 1 to 9 initially. On each turn, a player inputs a number, which
corresponds to a specific cell. The system validates the move and updates the board. The
winning logic checks all possible winning combinations after each move. The game
continues until a player wins or the board is full.
Algorithm and Explanation
1. Display the initial board.
2. Take turns between Player 1 and Player 2.
3. Get user input and validate.
4. Update the board and check if any player has won.
5. If no winner and the board is full, declare a draw.
6. Repeat until win/draw.
This approach teaches key programming constructs like loops, conditions, and modular
design.
Output Screens
After compiling and running the program, the output is shown in the console. The players
can interact with the board using numbers 1 to 9. After each move, the board updates and
shows current status. Messages display whose turn it is and if a player wins or if it’s a
draw. These outputs mimic a real-time two-player game experience.
Applications and Real-world Benefits
• Sharpens programming and logic-building skills
• Foundation for game development
• Understanding real-world problem conversion into code
• Useful for UI/UX design practice
• Enhances teamwork and group coding experience
Learning Outcomes
• Understood structure and logic of C language
• Learned to apply conditionals, loops, and user input
• Gained experience in team collaboration
• Practiced testing and debugging in real-time
• Improved understanding of game development fundamentals
Conclusion
This microproject provided a hands-on learning experience and helped in understanding
the practical implementation of theoretical knowledge. We successfully built a functional
Tic Tac Toe game using basic elements of C language. It gave us insights into how logic
and creativity can combine to develop meaningful applications. The team collaboration
and application of concepts made this project an enriching experience.
References
• Let Us C by Yashwant Kanetkar
• GeeksforGeeks - www.geeksforgeeks.org
• Tutorialspoint - www.tutorialspoint.com
• YouTube Programming Channels
Source Code
#include <stdio.h>
int main() {
char a = '1', b = '2', c = '3';
char d = '4', e = '5', f = '6';
char g = '7', h = '8', i = '9';
int turn = 1, move;
char mark;
while (1) {
printf("\n");
printf(" %c | %c | %c \n", a, b, c);
printf("---|---|---\n");
printf(" %c | %c | %c \n", d, e, f);
printf("---|---|---\n");
printf(" %c | %c | %c \n", g, h, i);
printf("\n");
if (turn % 2 == 1) {
mark = 'X';
printf("Player 1 (X), enter a number (1-9): ");
} else {
mark = 'O';
printf("Player 2 (O), enter a number (1-9): ");
}
scanf("%d", &move);
if (move == 1 && a == '1') a = mark;
else if (move == 2 && b == '2') b = mark;
else if (move == 3 && c == '3') c = mark;
else if (move == 4 && d == '4') d = mark;
else if (move == 5 && e == '5') e = mark;
else if (move == 6 && f == '6') f = mark;
else if (move == 7 && g == '7') g = mark;
else if (move == 8 && h == '8') h = mark;
else if (move == 9 && i == '9') i = mark;
else {
printf("Invalid move! Try again.\n");
continue;
}
if ((a == b && b == c) || (d == e && e == f) || (g == h && h == i) ||
(a == d && d == g) || (b == e && e == h) || (c == f && f == i) ||
(a == e && e == i) || (c == e && e == g)) {
printf("\n");
printf(" %c | %c | %c \n", a, b, c);
printf("---|---|---\n");
printf(" %c | %c | %c \n", d, e, f);
printf("---|---|---\n");
printf(" %c | %c | %c \n", g, h, i);
printf("\n");
printf("Player %d wins!\n", (turn % 2 == 1) ? 1 : 2);
break;
}
if (turn == 9) {
printf("It's a draw!\n");
break;
}
turn++;
}
return 0;
}