Question

Define the board space for a four-dimensional Tic Tac Toe board? (in C#) What is harder...

  1. Define the board space for a four-dimensional Tic Tac Toe board? (in C#)
  2. What is harder creating the data structure you thought of or writing the rules that support it? Give a detailed example.
  3. How do you pass a structure or an array to a function?
  4. If I declare a variable as follows: int x; please describe how that variable is represented in memory. What does &(x) return? What does *(x) return? What does *(&(x)) return?

Homework Answers

Answer #1

Define the board space for a four-dimensional Tic Tac Toe board?

Answer:- tic tcs toe is a very simple two player game. So only two players can play at a time. This game is also known as Noughts and Crosses game. In this game we have a board consisting of a 3*3 grid.

Game rule:-

  • tradittionaly the first player plays with "X". so you can decide who wants to go "X" and who wants go with "O".
  • only one player can play at a time
  • if any of the players have filled a square then the other player and the same player can't override that square.
  • the player that succeeds in placing three respective mark (X or O) in a horizontal, vertical or diagonal row wins the game.

Winning condition:-

Whoever places three respective marks(X or O) horizontally vertically or diagonally will be the winner.

How do you pass a structure or an array to a function?

Answer:- It can be done in below 3 ways:-

  1. Passing structure to a function bt value.
  2. Passing structure to a function by address(reference).
  3. No need to a struture - Declare structure variable as global.
  • A structure can be passes to any function from main function or from any sub function.
  • Sturcutre definition will be availabe withi the function only.
  • It won't be available to other functions unless it is passed to those funtions y value or by address(reference).
  • Else, we have to declare structure variable as global variable. That mean, stucture variable should be declared outside the main function. So, this structre will be visible to all te functions in a C program.

If I declare a varibale as follows: int x; please describe how that variable is represent in memory.

Answer:- To represent variable ,we have to follow:-

  • get the address and the size of the variable.
  • typecast the address to the character pointer to get byte address.
  • now loop for the size of the vaiable and print the value of typecasted pointer.

Example to represent variable"int x" in memory:-

#include <stdio.h>

typedef unsigned char *byte_pointer; //create byte pointer using char*

void disp_bytes(byte_pointer ptr, int len)

{ //this will take byte pointer, and print memory content

int i;

for (i = 0; i < len; i++)

printf(" %.2x," ptr[i]);

printf("\n");

}

void disp_int(int x)

{

disp_bytes((byte_pointer) &x, sizeof(int));

}

main() {

int i = 5;

disp_int(i);

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A Tic-tac-toe board has 9 spaces. The first player fills one of the spaces with an...
A Tic-tac-toe board has 9 spaces. The first player fills one of the spaces with an X, then the second player fills a space with an O. The players continue to alternate filling a space with their respective symbol until no empty spaces remain on the board. How many different arrangements of X’s and O’s are possible at the end of the game? You must fully justify your answer.
What is harder creating the data structure you thought of or writing the rules that support...
What is harder creating the data structure you thought of or writing the rules that support it? Give a detailed example.
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional char array with three rows and three columns as the game board. Each element in the array should be initialized with an asterisk (*). The program should run a loop that: • Displays the contents of the board array. • Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a 3x3 grid. The winner is the first player to place 3 consecutive marks in a horizontal, vertical or diagonal row. Understanding the Problem: In this assignment, you will: 1) Create a tic tac toe board data structure. 2) Check for game over. 3) Clear the tic tac toe game for each game. 4) Display the tic tac toe board to screen. 5) Simulate playing...
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values a variable cannot hold? How much memory will be reserved for the variable? What value a variable will hold? How the program will use the data type? Question 2 Using the structure below, which of the following statements about creating an array (size 20) of structures are not true? struct Employee{     string emp_id;     string emp_name;     string emp_sex; }; Question 2 options:...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's algorithm to ensure mutual exclusion in the respective critical sections of the two processes, and thereby eliminate the race condition. In order to implement Peterson's Algorithm, the two processes should share a boolean array calledflagwith two components and an integer variable called turn, all initialized suitably. We will create and access these shared variables using UNIX system calls relating to shared memory – shmget,...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
What role could the governance of ethics have played if it had been in existence in...
What role could the governance of ethics have played if it had been in existence in the organization? Assess the leadership of Enron from an ethical perspective. THE FALL OF ENRON: A STAKEHOLDER FAILURE Once upon a time, there was a gleaming headquarters office tower in Houston, with a giant tilted "£"' in front, slowly revolving in the Texas sun. The Enron Corporation, which once ranked among the top Fortune 500 companies, collapsed in 2001 under a mountain of debt...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended for undergraduate students in college or those under 18 years of age. Read these directions carefully! The below test includes 10 questions, randomly selected from a large inventory. Most questions will be different each time you take the test, You must answer at least 9 out of 10 questions correctly to receive your Certificate. You have 40 minutes to complete each test, and you...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT