CAS Community   >   Resources   >  

Program: Treasure Hunt using 2D Arrays

Guess where the treasure is by typing in row and column index numbers

Phil Gardner

Created by Phil Gardner
last edited Feb 27 2021 by Phil Gardner

C++ program for Raspberry Pi, Apple mac or Linux PC. Uses 2D arrays, data-types, constants, iteration and random numbers.

Load the source-code into your IDE, then build and run.

Alternatively, to compile the source-code from the command-line:

g++ -o treasure treasure.cpp

(This makes a new executable file called treasure.)

To run from the command-line:


You can also paste the code into and run from there.

Blog and other programs here.

Downloaded 68 times.


This resource has attached files: to access these files, please tick the box below to assent to the license terms
License: The resources on CAS website are under Creative Commons Attribution-Share Alike 3.0 licence unless otherwise specified by the resource creators.

You must confirm that you have read and agree the licence's ToS before you can download the attachments of this resource.

I have read the licence agreement of this resource and agree to abide by its terms and conditions.

Feedback and Comments

Available when logged in (join via the front page, for free):
  • View 0 comments on this resource.
  • View resource history, links to related resources.
  • Leave feedback for the author(s), or help by editing the resource.

© 2021 BCS, The Chartered Institute for IT Registered charity: No. 292786
Using the websiteDisclaimer of liabilityCookies policyPrivacy notice