You are on page 1of 2

Keth Iralex Cabalda BES 043

COC-FA-BSCE2-04 Module #16

Static Arrays

Activity 1: What I Know Chart

1. What is an array of memory location?


- It is a consecutive group of memory locations that all have the same name and the same type

2. Why is it called static array?


- It is called static array because it receives static memory allocation.

3. How to access arrays?


- To access arrays use the name of the array name followed by the index of the element in square
brackets.

Activity 3: Skill-building Activities

1. Write a program that will keep track of the score of the players solving for the sum of two (given by
the program) numbers. The two (max of 2-digit) numbers are randomly generated. There will be a
maximum of ten players, that means 2 can play, 4 players can play or 7 players. The player takes turn
answering while the program is tracking and displaying their score. The program ends if one of the
players reach the score 10.

Activity 5: Check for understanding,


Answer the following:

1. If an array int scores [ ] = {100, 20, 50, 80, 11}; is declared, what is the value of scores[2]?
- 50

2. What is wrong with the declaration and initialization below? char choices[4] = {‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’,
‘g’};
- too many initializers for 'char [4]'

3. If an array is declared as int stars [3] = {100, 20, 50}; what is wrong with the statement below? for (int
n=1 ; n<9 ; ++n ) stars [n] = n ;
- “n<9 was not declared in this scope”
4. What is the output for the following fragment of code?I
int data2[10] = {7, 5, 12, 4, 0, 6, 5, 0, 2, 98};
int x=0, t=0;
while(data2[x]!=0){
cout<<data2[x]<< ‘ ‘;
x+=2;
t +=data2[x];
if(t>=20) break;
}

- output are “ 7 and 12’

5. What is the first index location of an array?

- the first element has index (position) 0.

Activity 6: Thinking about Learning

Three things you learned:


1. Write an program that apply the static arrays.
2. I learned about static arrays
3. I learned how to trace data from codes with static arrays.

Two things that you’d like to learn more about:


1. More about writing program that apply static arrays.
2. More examples in static arrays.

One question you still have:


1. What are the advantages and disadvantages of using static arrays?

You might also like