Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
C++ Arrays (Lecture Activities)
Group Works
Exercise 1 (15 min)
1. Declare an array of integers scores with 4 elements.
2. Put in the array with the follows: 20, 15, 12, 47 3. Declare an array of string title with 4 elements. 4. Initialize the array with the follows: “Mid1”, “Mid2”, “Final”, “total”. 5. Print the two table of grads (score and title) using for loop. The output will as the follows
Mid1 20 Mid2 15 Final 12 Total 47
Exercise 2 (15 min)
1. Declare an array of string title with 4 elements.
2. Initialize the array with the follows: “Mid1”, “Mid2”, “Final”, “total”. 3. Declare an array of integers scores with 4 elements. 4. Use the loop to read from the scores array the three scores and calculate total and put the result in the fourth array element. 5. Declare an array of float percentage with 4 elements. 6. Calculate the percentage of the score in each of element, assuming that the full mark is 60 7. Print the three arrays. The output should be as follows
Enter your score in Mid1: 20
Enter your score in Mid2: 15 Enter your score in Final: 12
Mid1 20 33.3% Mid2 15 25.0% Final 12 20.0% Total 47 78.3%
Individual Works Write a program that reads 5 strings and print them in reverse order.