Page 292 - Computer_Science_F5
P. 292
Note: Use “isPrime” built-in Arrays and strings
function to display prime
numbers. Arrays
Suppose you are required to create a Chapter Four: Object oriented programming with C++
4. Write a C++ program that can help program that can help a teacher to read
FOR ONLINE READING ONLY
WAMO bank to calculate the total the marks of 50 students. To accomplish
amount of money (A) gained by this task you will have to declare 50
the customer after “n” number of variables each storing one mark of a
years. Given, the interest rate “R” student. Such a plan is entirely difficult
provided by the bank is 12%. The because you may not remember and
program will prompt the user to track the names of variables. To solve
enter the amount of money (P) such problem, you can store all marks
invested by the customer and then of 50 students using a single declaration
display the result on the computer of a variable. A typical data structure
to help you achieve this is known as
screen. Hint: Use the formula, an array. Figure 4.62 shows a structure
A = 1 ( P + R ) , Use function pow of array to solve a problem of creating
n
(a, b) for ab. numerous declarations.
Figure 4.62: A structure of array
An array is a collection of elements of the same data types that can be stored in a
fixed size, placed in a contiguous memory location, and that can be individually
283
Student’s Book Form Five
Computer Science Form 5.indd 283 23/07/2024 12:34

