Ask Question, Ask an Expert


Ask C/C++ Expert

Home >> C/C++

problem 1) Implement this function in C:

void populateGameBoard(char gameBoard[][COL_SIZE], int rowSize, int colSize, int numPieces);

This function takes in entire game board passed from main, the row size, the column size of the playable game board, and number of pieces to place (num_pieces). Inside the function develop the way to populate 2D array randomly by calling getPieceType (basically function which randomly generates (returns) character of either 'T' or 'A') to obtain either ‘A’ or ‘T’ to place on the playable game board portion up to the size of numPieces. numPieces is decided by the row size of the 2D array -- meaning that if rowSize = 10, then the board would start with 10 game pieces.

Note: This function also should handle the case that max element size would be met and number of units plus incoming number pieces would create an infinite loop. Develop the way to prevent the infinite loop.

A solution is below

For ex: a 3 * 3 game board has at max 9 elements but also requires a placement of 3 additional units, but already 7 units present on game board. If this is the case decrement the number of additional units to fit the max number of units in the playable game board portion.


Player's life left is [100]

Number of devastor missiles is [0]

Player's score is [0]

    a     b      c    d     e     f     g     h      i      j
a [   ] [   ] [   ] [   ] [   ] [   ] [   ] [ A  ] [   ] [   ]
b [   ][ T ] [   ] [   ] [   ] [   ] [   ] [   ] [   ] [   ]
c [   ] [   ] [   ] [   ] [ A  ] [   ] [   ] [   ] [   ] [   ]

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M94704

Have any Question? 

Related Questions in C/C++

Assignmentgoals developing problem-solving skills declaring

Assignment Goals: Developing problem-solving skills, declaring variables, multi-way branches, data validation. Problem: Complete Programming Challenge 4.19 in your text book. Do not accept values larger than 10 meters or ...

C projectphase 11- you need to take input from user study

C project Phase 1 1- You need to take input from user study year (proper value check from 1 to 4) 2- Take input semester (proper value check 1 to 8) 3- Calculate GPA (use Loop, calculate GPA for semester 1,2,3...) Exampl ...

Object-oriented programming assignmentintroduction -nbspa

Object-Oriented Programming Assignment Introduction -  "A logical matrix or (0, 1) matrix is a matrix with entries from the Boolean domain B = {0, 1}. Such a matrix can be used to represent a binary relation between a pa ...

Assignmentthis is the programthis program will use 2

Assignment This is the program: This program will use 2 different data structures to perform the same tasks; a vector and a dynamically sized array Write a complete C++ program that will: Declare a vector of integers wit ...

1 write a c program that includes a function called lobster

(1) Write a C program that includes a function called lobster() that accepts three arguments: a character and two integers. The character argument is the character to be printed by lobster(). The second argument is the n ...

Discussionkeyboard versus file input please respond to the

Discussion "Keyboard versus File Input" Please respond to the following: • Suppose you are designing a C++ application that needs to capture user input specifically via a keyboard or from a file. Determine the method tha ...

Write a c program that prompts the user to enter a line of

Write a C program that prompts the user to enter a line of text (up to 50 characters). It should then convert the text entered to uppercase letters and then to lowercase letters, and then to Sentence case. Your program s ...

Assignmentwhen writing c programs include comments in your

Assignment When writing C++ programs include comments in your code, make the program readable by indenting, use meaningful variable and function names, and produce meaningful output. This assignment will be to write a bm ...

Write a c application that does the followingitem 1 prompts

Write a C++ application that does the following: ITEM 1: Prompts the user to choose one of the following series: 1 + 1/2 + 1/3 + ... + 1/n ((((x * 2) * 2) * ...) * 2) series of n multiplications x + (x * 1) + (x * 2) + ( ...

Writing a c code its a beginner level code design a class

Writing a C++ code, its a beginner level code. Design a class house that defines a house on a street. A house has a house number and an (x,y) location, where x and y are numbers between -10 and 10. the key member is plot ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro