

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This assignment was given by Dr. Jyoti Lokesh at Biju Patnaik University of Technology, Rourkela for Computer Programming course. It includes: Dimensional, Char, Array, Player, Wrong, Indices, Row, Column, Binary, Search, Algorithm
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Course No. CS Course Title Computer Programming
Deadline: Monday 30th^ April, 2012 12:0pm
In this part of assignment you shall implement Tic-Tac-Toe (a two-player game) using a two- dimensional char array. You shall initialize the game board (saved as char array) with character 'v'. Therefore, at start of the game the tic-tac-toe board looks like: v v v v v v v v v Player-1 is assigned 'X' symbol and player-2 is assigned 'O' symbol. Player-1 shall start the game and enter row index and column index where (s)he wants to place an 'X'. The board is updated and displayed. Now player-2 is asked to enter row and column indices. One possible run of game is as follows:
v v v v v v v v v Player1- enter row and column: 0 0 X v v v v v v v v Player2- enter row and column: 0 1 X O v v v v v v v Player1- enter row and column: 1 1 X O v v X v v v v Player2- enter row and column: 2 2 X O v v X v v v O Player1- enter row and column: 1 0 X O v X X v
v v O Player2- enter row and column: 2 1 X O v X X v v O O Player1- enter row and column: 2 0 X O v X X v X O O Player 1 wins
If any player tries to enter wrong indices e.g. row=3 column=2 then the program should display a message "Invalid choice - try again". Similarly, if the player tries to enter indices where an 'X' or 'O' is already present then again the program responds by a message "Invalid choice - try again". One possible program run is as follows:
v v v v v v v v v Player1- enter row and column: 3 2 Invalid choice - try again Player1- enter row and column: 1 1 v v v v X v v v v Player2- enter row and column: 0 2 v v O v X v v v v Player1- enter row and column: 1 1 Invalid choice - try again Player1- enter row and column: 2 0 v v O v X v X v v Player2- enter row and column: 2 2 v v O v X v X v O Player1- enter row and column: 1 2 v v O v X X X v O Player2- enter row and column: 1 0