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++

Assignment a random mazewrite a new c program with the

Assignment (a) Random Maze Write a new C++ program with the following functionality: The program writes a greeting on the screen. Then the program displays a maze of ASCII symbols on the screen. The maze consists of 8 ro ...

C-programmingcreate a c program that sorts a sequence of

C-Programming Create a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an increasing or decreasing order based on the user's choice. The pseudo code for the bubble sort algorithm is ...

Programming in c assignmentwrite a c program that computes

Programming in C Assignment Write a C program that computes and outputs the current age of the United States in days (you can use 1776 as theUS founding year). You don't have to worry about fractional years or leap years ...

Programming assignment image processing - pointers class

Programming Assignment: Image Processing - Pointers, Class & Dynamic Data This project is called "Image Processing" which will shrink an input image, convert a color image to gray image , add random noise to an image, ad ...

Practice with pointers and dynamic memory

Practice with pointers and dynamic memory allocation Problem: Write a C++ program that will implement and test the four functions described below that use pointers and dynamic memory allocation. The Functions: You will w ...

Modules in c are called functions c programs are typically

Modules in C are called functions. C programs are typically written by combining user created functions as well as "pre-packaged" functions found in the C Standard Library. For instance, printf() is a function that is fo ...

Assignmentobjectivespractice reading characters from a

Assignment Objectives Practice reading characters from a file Practice using command line input Practice using command-line redirection of files Practice implementing a double transposition ciphering algorithm Summary In ...

Assignment part acreate a checkbook program using c

Assignment (part a) Create a Checkbook program using C : • Create a Check structure. Include:   o Check number (should be an integer).   o Date (use type char[ ]).   o To   o Amount   o Description • Add functions to:   ...

Cs 2410workshop make-up assignmentwrite a c program that

CS 2410 Workshop Make-Up Assignment Write a C++ program that will output to a file called output.txt EVERY 10 digit phone number from 713-000-0000 through 713-000-0998. These numbers MUST only contain an odd number of ev ...

Intro to programming in c assignmentsince this is the last

Intro to Programming in C Assignment Since this is the last assignment, there will be no late submission. All programs must be electronically submitted by 5:00pm on Tuesday, December 2nd with NO EXCEPTIONS in order to re ...

  • 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