You are on page 1of 1

CSC402 – Array Exercise 1

1. Write a program that uses array to store the following:

30.0, 45.7, 60.6, 30.5

And then process the data and generate the following output:

N X (length in cm) square(X)


1 30.0 900.0
2 45.7 2088.49
3 60.0 3600.0
4 30.5 930.25

2. Write a C++ program that declares an array alpha of 50 components of the type
double. Initialise the array so that the first 25 components are equal to the square of
the index variable and the last 25 components are equal to three times the index
variable. Output the array .

3. Write a program that allows the user to enter the number of votes received by five
candidates. The program should then output the number of votes received and the
percentage of the total votes received by the candidate. Your program should also
output the winner of the election. A sample output is:

Candidate Votes Received % of Total Votes


1 5000 25.91
2 4000 20.72
3 6000 31.09
4 2500 12.95
5 1800 9.33
Total 19300
The winner of the Election is 3

You might also like