Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Lab 07 – Arrays. 

Reminder if VS gives you a warning about scanf you can disable this by doing the following :

Either place this line at the top of your program :

#define _CRT_SECURE_NO_WARNINGS

Or in your project go to the file menu project -> properties.

In the window go to the C/C++ , preprocessor then in the Preprocessor definitions enter the line :

_CRT_SECURE_NO_WARNINGS

Exercise 1.

Write a program that asks the user to enter 15 integers.  Once the user has entered the integer, the program should output the following :

i) The sum of all the integers.

ii) The average of the integers.

iii) The list of integers in reverse order.

Exercise 2.

Write a program that asks the user to input a word.  The program should then check whether the user has entered a palindrome(*).

(*) Palindromes are words or phrases that are spelt the same backwards as they are forward Eg. rotor, radar and level are all palindromic words.

Exercise 3.

Write a program that asks the user to enter two words.  The program should then check if one word is an anagram(*) of the other.

(*) Anagrams are words that contain exactly the same letters as another word but in a different order Eg. carthorse is an anagram of orchestra.

Exercise 4.

a) Consider the table below :

Robot Number

Speed

Weight

Max. Run-Time

Price

1.0

4.5

5.6

12.7

495.99

2.0

5.6

8.9

8.2

599.95

3.0

2.1

14.6

6.5

399.95

4.0

7.9

6.4

3.4

749.65

The table gives information about 4 mobile robots :

Top Speed (m/s), Weight (Kg), Maximum Run-Time on a full battery (Hours), Price (£).

Write a program that stores the information in a single array, and allows the user to change any value (including robot number).  The program should also allow the user to select the following information when requested via a simple menu:

i) The fastest / slowest robots.

ii) The heaviest / lightest robots.

iii) The robots with the best / worst maximum run-time.

iv) The cheapest / most expensive robots.

v) The average speed of all the robots.

vi) The average Weight of all the robots.

vii) The average runtime of all the robots.

viii) The average price of all the robots.

ix) All the details of any one robot.