Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A . Discussion : At what point should you consider changing from individual vari

ID: 3597793 • Letter: A

Question

A. Discussion: At what point should you consider changing from individual variables to an array? Is it reasonable to use an array when you only have two or three items to track? Why or why not? Consider the number of sets of those two or three items when making your decision.

B. Write the pseudocode to do the following:
1. Use arrays to store data for student names, ID number, and gender into an array (tip: parallel arrays)

2. Print the contents of each record using the array

3. Count the number of male and female students by using the array, and print the counts.

Explanation / Answer

If we have less number(2 or 3) of items, we don't need to go for arrays, but if
we have more than that it is better to switch to arrays. It is because a lot of
repetition of statements we can avoid with for loops

We can have 3 arrays .one for names, one for IDs and one for gender such that
ith value in each array are linked with each other

string names[3]
string id[3]
char gen[3]

names[0] = "name1"
names[1] = "name2"
names[2] = "name3"

id[1] = "123"
id[2] = "345"
id[3] = "567"

gen[0] = 'F'
gen[1] = 'M'
gen[2] = 'F'

for (int i i<3 i++)
   print( names[i] , id[i], gen[i])

countMale = 0
countFemale = 0
for (int i i<3 i++)
    if (gen[i] == 'F')
        countFemale++
    else
       countMale++

print(countMale)
priny(countFemale)