0
Can you help me?
what syntax and loop would I use to iterate through the array to calculate the average number of letters per name?
3 ответов
0
you can use for
0
You could do it by taking a name as input, storing them in an array, then write a loop that, for reach element in the array, adds the length of each element to another variable, which is then divided by the length of the array.
Pseudocode:
arrayOfNames = []
inputName as input
add inputName to array
averageName method:
lengthOfArray = 0
lengthOfNames = 0
for each name in arrayOfNames:
lengthOfArray += 1
lengthOfNames += len(name)
averageOfNames = lengthOfNames / lengthOfArray
print averageOfNames
END of method
averageName(inputName)
0
Sorry, please see edit