Problem 1. Tic-Tac-Toe, Part 1 (20 points) Write a program that declares a 2 dim
ID: 3606736 • Letter: P
Question
Problem 1. Tic-Tac-Toe, Part 1 (20 points) Write a program that declares a 2 dimensional array of chars with 3 rows and 3 columns. Write functions called initializeBoard0, displayBoard0, and makeMove0). initializeBoard0 should fill the array with space characters(, display Board0 should display the current board, with the rows and columns labled, and makeMove) should ask the user to enter a row and a column and change that square to alternating X's or a O's. Display the board again after each move. The program should run for 9 moves. Name your code as Hw5_q1 code.c Use the following function prototypes void initializeBoard(char board[][3]); void displayBoard(char board[II3); void makeMove(char board1131, char player); (TIP: use scant("%d %d", &row;, &column;); use char board[3113];) Example Hints, Inputs and Outputs: (purple texts are what the program should print on the screen to instruct the users, the black texts are what the users type in) 2 3I Enter the row and column you'd like to fil1:2 2 2 o] Enter the row and column you'd 1ike to fill:3 3 1 23 2 o] 3 [X] Enter the row and colm you'd like to fil1:1 1 1 [o) 2 1o)Explanation / Answer
#include<stdio.h>
int main(){
int disp[2][3];
int i, j;
for(i=0; i<2; i++) {
for(j=0;j<3;j++) {
printf("Enter value for disp[%d][%d]:", i, j);
scanf("%d", &disp[i][j]);
}
}
printf("Two Dimensional array elements: ");
for(i=0; i<2; i++) {
for(j=0;j<3;j++) {
printf("%d ", disp[i][j]);
if(j==2){
printf(" ");
}
}
}
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.