C++ Array Exercises

Using your knowledge so far (basic, loops, conditional tests, functions and mainly arrays), solve the following exercises in C ++ and put your code in the comments.

C ++ Array exercises

01. Write a program that will receive and store 10 numbers in an array. Then, you must create two functions that will find the highest and lowest value of that array.

02. You were hired by a TV station to make C++ software to work with rain data in your city. Your 7-position array should store how much it rained each day. Then, you must say which day it rained more, the day it rained less, how much it rained the week and the average, to show on TV.

03. Create an array of 10 positions, to store the average grades of 10 students. Your program must then go to each grade and check if the student has passed (grade higher than 7), failed (grade less than 5) or will be left for recovery (grade between 5 and 7).

04. Create a lottery number generator program. That is, create an array of 6 positions and in each position draw a number from 1 to 60. Oh, your numbers cannot be repeated.


05. Make a program in which you will supply 10 numbers for an array, including repeated values. Your code must search this array to create a new array that does not have repeated numbers.


06. Program the tic-tac-toe, in C++. Two players on your computer must be able to play. Each player says a line and a number, on the 3x3 board, to play (can only play in free spots on the board). At the end of each game, it must say who won or drew, as well as the score of the game, and whether they want to play another game or close the program.
Tic-Tac-Toe in C++


07. On an NxN board (you choose N), the computer must draw N positions on that board, without the user knowing. These positions are the ships locations. Now you must make attempt (shots in the water) to try to hit the ships. With each shot you take, the program should tell you whether you hit or miss, and if you miss, it should tell you how many ships are there around that point.



More exercises, with solutions, on C ++ arrays:
https://www.w3resource.com/cpp-exercises/array/index.php

No comments:

Post a Comment