exciting questions - please help

Category: Latest Topics    |    1 views    |    Add a Comment
A programmer has been asked to implement a simple game that requires the use of a board to position and manipulate some objects represented by symbols.
The programmer has implemented the board as a two-dimensional array of characters. The following constants have been declared as global to the whole program:
const int ROWS( 20); //vertical dimension
const int COLS( 10); //horizontal dimension
The main program (i.e., top level algorithm) contains the following local variable declaration:
chartheGrid[ ROWS+1][COLS+1];
In the questions below you are asked to write three C++ functions that will be called from the main program. Some of them will use a 2D array such as theGrid passed as a parameter.
You may assume that when asked to enter a grid reference (column or row number) the user types in a number and that the values needed for any computation exist in the array theGrid.
Where appropriate, you should:
• write down any assumptions that you may make,
• assume that the global variables used are already declared,
• declare any new local variables used,
• use meaningful names, clear indentation and comments.
You must NOT use recursion.
Marks will be given for the style of your solutions and how easy they are to read and understand.

1. Write a C++ function, called inputValidNumber, which prompts the user for a value in a given range, reads in a number, checks that it is in a range specified and returns it. While the value read in is not in the specified range, the system repeatedly asks for another one until a valid value is input.
The function takes 2 parameters respectively representing the minimum and maximum of the valid range (both inclusive) and returns the valid value read in.

For example, the following statement sets the value of a variable number to the first number input by the user that is greater than or equal to 1 and less than or equal to20.
intnumber = inputValidNumber( 1, ROWS);

2. Write a C++ function, called findMousePosition, which looks for the position of the mouse on the board.
The mouse is represented in the array theGrid by the character ‘@’.
The function takes three parameters: the first one is an array that represents the current configuration of the board, the second and third onesare respectively set to the row and column numbers of the cell that contains the mouse.
You may assume that there is always a single mouse is on the board.

For example, the following statement sets the value of the integer variables rowMouseandcolMouse to the coordinates of the character ‘@’ in the array theGrid.
findMousePosition( theGrid, rowMouse, colMouse);

3. Write a C++ function, called countApples, which counts the number ofapplescurrently on the grid, i.e., number of cells that contain the character ‘O’ used to represent an apple.
The function takes two parameters: the first one is an array that represents the current configuration of the board and the second one represents the number of apples it currently contains.

For example, the following statement sets the value of the integer variable totalApples to the number of times (may be 0) the character ‘O’ is present in the array theGrid.
countApples( theGrid,totalApples);

Share/Save/Bookmark

 

Which way is reliable for message ?

Category: Web Questions    |    1 views    |    Add a Comment
Hi,

I insert data into database with submit button. When insert is successful, a message box appears on the screen which is shown below. Now, user must click on "Ok" on that message to be able to continue. Is this effect concurrency in MySQL database because, several people use this page. Shall i just use echo to print same message on the page instead?

Thanks

<script>alert("Data inserted");</script>

Share/Save/Bookmark

 

Purpose of WHERE 1=2" ?

Category: Latest Topics    |    4 views    |    Add a Comment
Hi all!

Can any one explain what is the purpose of

WHERE 1=2"

What the statement means. in below code?

query = "SELECT * FROM project WHERE 1=2"

Thanks in advance

Regards,
Elanch

Share/Save/Bookmark

 

Link Back Code

Category: Web Questions    |    2 views    |    Add a Comment
Hi, this is the code

Link to us:<br>
<form><textarea cols="110" rows="3" onClick=’highlight(this);’><a href="<? echo $url; ?>">
<img src="<? echo $url; ?>/button.gif"></a></textarea></form>
<br>
<a href="<? echo $url; ?>">
<img src="<? echo $url; ?>/button.gif"></a>

</div><br><br>

This is the code at this Tools Page
I am having problem for linkback. the code doesn’t seem to work. Plus the url generated in example is http://free-images-upload.com/www.fr…ges-upload.com

Please help me see what is wrong. thanks very much

Share/Save/Bookmark