Professional Documents
Culture Documents
Page 1/2
5. Write a complete C program to ask the user for the elements of a 2x5 type double array
named array (input is to be entered row by row). Then display the sum of the values in each
row and of each column as follows for example
| Row Sum
1.0 2.5 3.0 4.5 0.5 | 11.5
2.0 3.0 1.0 1.5 2.0 | 9.5
______________________________|
Column Sum 3.0 5.5 4.0 6.0 2.5
6. In a tic-tac-toe game, the board can be represented by the array:
char board [3][3], where each cell can contain the value ‘X’, ‘O’, or ‘-‘ (where ‘-‘ represents
an empty cell). Assume that player X plays first.
a. Write a function that initializes the board for a new game.
b. Write a function that checks if the board is full or not.
c. Given the board of a game that hasn’t ended yet, write a function that determines
who’s turn is now. (Assume that player X plays first)
d. Write a function to check if ‘X’ is the winner.
e. Generalize the above function to check who is the winner
f. Write a complete working tic-tac-toe game.
GOOD LUCK ☺!
Page 2/2