Aman
Aman
Aman
REPORT
ON
INDUSTRIAL TRAINING ON
“Programming with C and C++”
Taken at
INTERNSHALA TRAININGS
In partial fulfillment of the requirement for the award of degree of
Bachelor of Technology
In
Department of Artificial Intelligence & Data Science
(Session 2024-25)
Duration :
1
INDEX
1. Certificate 4
2. Declaration 5
3. Preface 6
4. Acknowledgment 7
5. Company Profile 8
7. What is C? 9-10
7.1 Overview of C 9
7.2 Features of C 9
8.1 Overview 11
8.2 Features 12
8.7 Screenshots 17
9. Conclusion 22
11. References 24
2
Certificate of Training
This is to certify that the report of the training submitted is the outcome of the practical training done at
Intershala Trainings. in “C & C++ Programming” is carried out by Aman Jat bearing RTU Roll No.:
23EJCAD023 under the guidance and supervision . for the award of Degree of Bachelor of Technology
(B.Tech.) in Department of Artificial Intelligence & Data Science from Jaipur Engineering College &
Research Centre, Jaipur (Raj.), India affiliated to Rajasthan Technical
University, Kota during the academic year 2024-2025.
To the best of my knowledge the report
• Embodies the work of the candidate.
• Has duly been completed.
• Fulfills the requirement of the ordinance relating to the bachelor of technology degree of the
Rajasthan technical University and
• Is up to the desired standard for the purpose of which is submitted.
I hereby declare that the report entitled “Programming with C and C++” has been carried out and
submitted by the undersigned to the Jaipur Engineering College & Research Centre, Jaipur
(Rajasthan) in an original work, conducted under the guidance and supervision of Mr.
Madhusudhan of INTERNSHALA.
The empirical findings in this report are based on the data, which has been collected by me. I have
not reproduced from any report of the University neither of this year nor of any previous year.
I understand that any such reproducing from an original work by another is liable to be punished in
a way the University authorities’ deed fit.
4
PREFACE
The main objective of this training is to create awareness regarding the application of theories in the
practical world of AI&DS and to give a practical exposure of the real world to the student.
I, therefore, submit this project report of this training, which was undertaken with Internshala
Trainings. It was a good experience to have training in a Reputed Learning Organization in the C
and C++ languages.
I feel great pleasure to present this project report. The report was prepared to brief about my
training project ‘a mini game collection’.
5
ACKNOWLEDGEMENT
“Any serious and lasting achievement or success, one can never achieve without the help, guidance
and co-operation of so many people involved in the work.
It is my pleasant duty to express my profound gratitude and extreme regards and thanks to Mr.
Sarvesh Agarwal who gave me an opportunity to take professional training in Internshala.
I am indebted towards Mr. Madhusudhan who has allotted this project and his precious time and
advice during the training period, which is imminent to the report.
I would like to express deep gratitude to Dr Manju Vyas, Head of Department (Artificial
Intelligence and Data Science), Jaipur Engineering College & Research Centre, Jaipur (Rajasthan)
without whose permission the training would not be possible. I would also like to thank Ms. Rahul
Guha, Assistant Professor, Department of AI&DS JECRC, Jaipur who recommended me for this
training.
Last but not the least, I am grateful to GOD for blessing me. I am heartily thankful to those people
who are involved directly or indirectly in this project for encouraging me whenever I needed their
help in spite of their busy schedule.
Aman Jat
23EJCAD023
6
COMPANY PROFILE
Services: Internshala Trainings offers various services designed to enhance students’ learning
experiences and career prospects:
2. Hands-on Practice: Interactive quizzes, tests, and projects that allow students to apply their
knowledge in real-world scenarios.
7
WHAT IS C?
1. Low-Level Access: C provides low-level access to memory using pointers, which allows
for efficient manipulation of hardware resources.
2. Simple Syntax: The language’s syntax is clean and easy to understand, making it a great
starting point for learning more complex languages.
3. Standard Library: C comes with a comprehensive standard library that includes functions
for input/output operations, memory management, string handling, and more.
4. Portability: C code can be compiled and run on various platforms with minimal changes,
making it highly portable.
5. Efficiency: Programs written in C are generally faster and more memory-efficient compared
to those written in higher-level languages.
Applications in Game Development: C is widely used in game development due to its
performance and close-to-hardware capabilities. Many classic and modern games, as well as game
engines, are built using C or C-based languages (like C++). Here’s why C is a good choice for game
development:
8
1. Performance: Games often require real-time performance and efficient memory usage. C
allows developers to fine-tune their code for maximum performance.
2. Hardware Control: Games frequently need to interact with hardware components like
graphics cards and input devices. C’s ability to handle low-level operations makes this
possible.
3. Game Engines: Many game engines, including early versions of famous engines like
Unreal Engine, have been developed in C. These engines provide the backbone for
numerous popular games.
9
MINI GAME COLLECTION
Overview:
This project involves the development of a mini game collection using the C programming
language. The collection includes four classic games: Tic Tac Toe, Guess the Number,
Hangman, and Rock Paper Scissors. The primary objective of this project is to leverage the
capabilities of C to create interactive and engaging games, demonstrating the language's
efficiency and versatility in game development.
C is renowned for its performance, efficiency, and close-to-hardware capabilities, making it an
ideal choice for game development, particularly for games that require real-time performance
and efficient memory usage. With its rich history and continued relevance, C serves as a
foundational language for many programmers, offering a stepping stone to more complex
programming concepts and languages.
This project not only aims to provide a fun and educational experience for users but also to
highlight the practical applications of C programming in real-world scenarios. By developing a
collection of classic games, we illustrate how fundamental programming concepts can be
applied to create functional and entertaining software.
In today's fast-paced digital world, games play a crucial role in entertainment, education, and
even cognitive development. By choosing to develop these particular games, we ensure a blend
of simplicity and challenge, suitable for a wide audience. Each game in the collection presents
unique programming challenges, from handling user input to managing game state and logic,
thereby showcasing the broad spectrum of capabilities offered by the C programming language.
10
Features:
1. Interactive Gameplay: Each game in the collection provides a dynamic and engaging user
experience, ensuring players remain interested and entertained throughout their play sessions.
2. User-Friendly Interface: The games feature simple, text-based interfaces that are easy to
navigate, making them accessible to players of all ages and skill levels.
4. Error Handling: The games include basic error handling mechanisms to manage invalid inputs
and ensure smooth gameplay. For instance, user prompts are clear and guide players in making
valid selections.
5. Modularity: Each game is implemented as a separate function, ensuring the code is modular and
easy to maintain. This modularity also makes it straightforward to add new games to the collection
in the future.
6. Educational Value: The project serves as an excellent educational tool, helping learners
understand and apply fundamental programming concepts such as loops, conditionals, arrays,
functions, and random number generation through practical application.
7. Scalability: The design of the mini game collection allows for easy scalability. New games can
be added without major modifications to the existing codebase, making it a versatile framework for
future expansions.
8. Cross-Platform Compatibility: The games are developed in C, ensuring they can be compiled
and run on various platforms with minimal changes. This cross-platform compatibility broadens the
reach and usability of the game collection.
9. Replayability: The games are designed to be replayable, providing different outcomes and
experiences with each playthrough. This keeps the games fresh and enjoyable over time.
11
10. Resource Efficiency: The games are optimized for performance, ensuring they run smoothly
even on systems with limited resources. This efficiency is achieved through careful management of
memory and processing power.
11. Customizability: The code is written in a way that allows for easy customization. Players and
developers can modify game parameters, such as difficulty levels, to suit their preferences and
needs.
12
GAME 1: GUESS THE NUMBER
"Guess the Number" is a simple yet engaging game where the player attempts to guess a randomly
generated number within a specified range, typically between 1 and 50 in this implementation. The
game provides feedback after each guess, indicating whether the guess is too high, too low, or
correct. The player must guess the correct number within a limited number of attempts.
The main goal of the game is to guess the correct number. It tests and enhances the player's ability
to make educated guesses and use logical reasoning based on the feedback provided. The game is
implemented using the C programming language, leveraging fundamental concepts such as loops,
conditional statements, and functions.
Code Explanation:
Random Number Generation: The [srand(time (0))] function seeds the random number generator
with the current time to ensure different random numbers in each game session. The [rand () % 50 +
1] expression generates a random number between 1 and 50.
Main Loop: The game runs a loop that repeatedly prompts the player for their guess using
[scanf(“%d”, &guess)]. After each guess, the number of attempts is incremented.
Feedback: Based on the player’s guess, the program provides feedback. If the guess is higher than
the target number, it outputs “Guess a smaller number!” If the guess is lower, it outputs “Guess a
bigger number!” If the guess is correct, it congratulates the player and exits the function.
Attempt Limit: The game allows up to 7 attempts. If the player fails to guess the number within
this limit, the game reveals the correct number and exits with a message.
13
GAME 2: TIC-TAC-TOE
Tic Tac Toe is a classic two-player game where players take turns marking 'X' and 'O' on a 3x3
grid. The first player to align three of their marks horizontally, vertically, or diagonally wins the
game. This implementation features a human player and a computer opponent.
The main goal is for players to achieve a sequence of three consecutive 'X' or 'O' marks. The game
tests strategic thinking and foresight, as players must plan their moves while anticipating their
opponent's actions.
Code Explanation:
Initialization: The [initializeBoard()] function sets up an empty 3x3 grid.
Print Board: The [printBoard()] function displays the current state of the board with row and column
indices.
Win Check: The [checkWin()] function checks if a player has won by forming a line horizontally,
vertically, or diagonally.
Draw Check: The [isDraw()] function checks if the board is full and the game is a draw.
Player Move: The [playerMove()] function captures the player's move and updates the board.
Computer Move: The [computerMove()] function randomly selects an empty cell for the
computer's move.
Game Loop: The main game loop alternates between player and computer moves, checking for a win or
draw after each move.
14
GAME 3: ROCK, PAPER AND SCISSORS
Rock Paper Scissors is a classic hand game that has been enjoyed by people of all ages around the
world for generations. In this game, two players simultaneously form one of three shapes with their
hand: Rock, Paper, or Scissors. The rules are simple but engaging: Rock crushes Scissors, Scissors
cut Paper, and Paper covers Rock.
In this implementation, the player competes against the computer, which randomly selects its
choice. The game provides immediate feedback, displaying both the player's and the computer's
choices and announcing the winner of each round. The straightforward interface and quick play
make Rock Paper Scissors a fun and accessible game for users of all ages. The main goal of the
game is to choose an option that defeats the computer's choice. The game tests the player's decision-
making skills and adds an element of unpredictability due to the computer's random selection.
Code Explanation:
Header Inclusions: The program includes the necessary header files for standard input/output
functions and random number generation.
Random Choice Generation: The [srand(time(0))] function seeds the random number generator
with the current time to ensure different random choices in each game session. The [rand() % 3]
expression generates a random choice for the computer.
Player Input: The game prompts the player to enter their choice (0 for Rock, 1 for Paper, 2 for
Scissors) using [scanf("%d", &player)]. The loop ensures the player makes a valid choice.
Outcome Determination: The game compares the player's choice with the computer's choice and
determines the outcome using conditional statements. It prints whether the player wins, loses, or ties.
15
GAME 4: HANGMAN
Hangman is a word guessing game where the player attempts to guess the letters of a hidden word
within a limited number of attempts. The game provides a hint to help the player guess the word.
It's a classic game that tests vocabulary, spelling skills, and logical thinking.
The main goal of the game is to guess the hidden word by suggesting letters within a limited
number of attempts. The game tests the player's vocabulary and deduction skills.
Code Explanation:
1. Word List and Hints: The game includes a predefined list of word- hint pairs. Each pair
contains a word and a corresponding hint to help the player guess the word.
2. Random Word Selection: The program calculates the number of word-hint pairs in the list
and uses the current time to seed the random number generator. It then selects a random
index to pick a word and its hint from the list.
3. Initialization: The length of the selected word is determined, and an array of underscores
(representing unguessed letters) is initialized. This array is used to display the current state
of the guessed word to the player. Additionally, the number of attempts allowed is set to 5,
and a variable is initialized to keep track of correctly guessed letters.
4. Main Game Loop: The game enters a loop where the player can guess letters until either all
letters are correctly guessed or the player runs out of attempts.
5. Game Outcome: After exiting the loop, the game checks whether the player successfully
guessed the entire word or ran out of attempts. It then displays an appropriate message: a
congratulatory message if the player won, or a message revealing the correct word if the
player lost.
16
SCREENSHOTS
17
18
19
20
CONCLUSION
This mini game collection project, developed using the C programming language, successfully
demonstrates the versatility and efficiency of C in creating interactive and engaging applications.
By integrating four classic games—Tic Tac Toe, Guess the Number, Hangman, and Rock Paper
Scissors—we showcased the broad range of capabilities offered by C, from handling user input to
managing game state and logic.
Through this project, we aimed to create a user-friendly and enjoyable game collection that could
be easily expanded and customized. The games' simple text-based interfaces ensure accessibility for
players of all ages and skill levels, while the elements of randomness and replayability keep the
gameplay fresh and exciting.
Additionally, this project serves as an excellent educational tool for aspiring programmers. It offers
hands-on experience with core programming concepts and emphasizes the importance of user
feedback, error handling, and maintaining a clean and modular codebase. By working on these
games, learners can enhance their problem-solving skills, logical reasoning, and strategic thinking.
In conclusion, the mini game collection project successfully demonstrates the enduring relevance of
the C programming language in modern software development. It provides a robust foundation for
both entertainment and education, showcasing the power and flexibility of C in creating interactive
and efficient applications. The project underscores the importance of C in game development and
its continued significance in the broader programming landscape.
21
FUTURE SCOPE
1. Additional Games: Add more games like Sudoku, Minesweeper, and Memory Match
to increase variety.
5. Sound and Music: Add sound effects and background music to make the games
more immersive.
6. Educational Features: Include tutorials and help sections to guide new players and
provide learning modes with hints and tips.
7. Mobile and Web Versions: Develop mobile apps for Android and iOS and create a web-
based version to make the games accessible on various devices.
These enhancements will improve the user experience and demonstrate the ongoing relevance and
potential of the C programming language in modern software development.
22
REFERENCES
Books:
Online Training:
Websites:
Google: https://www.google.com
Programiz: https://www.programiz.com/c-programming
23