0% found this document useful (0 votes)
211 views

CSC402 - Array Exercise 1

The document contains instructions for 3 array exercises: 1) Store and process data to output values and their squares. 2) Declare an array and initialize the first half with square indexes and second half with triple indexes. 3) Allow user input of votes for 5 candidates, output votes, percentages, totals and identify the winner.

Uploaded by

MAZIAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
211 views

CSC402 - Array Exercise 1

The document contains instructions for 3 array exercises: 1) Store and process data to output values and their squares. 2) Declare an array and initialize the first half with square indexes and second half with triple indexes. 3) Allow user input of votes for 5 candidates, output votes, percentages, totals and identify the winner.

Uploaded by

MAZIAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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