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

Question 1: A: What is the main difference between standard variables and arrays

ID: 3744720 • Letter: Q

Question

Question 1: A: What is the main difference between standard variables and arrays?

Question B: What is the relationship between length and the valid indexes of an array?

Question C: Why do we need to pass a size as well as the array to any function/procedure where we want it to use this array?

Question D: For loops are great for working with arrays, but can they be used without an array? Why may you want to do this?

Question E: How could you print out the names in the array starting with the last name and working back to the first name?

Explanation / Answer

Question 1: A: What is the main difference between standard variables and arrays?
Answer: Standard variable can hold one value at a time where as arrays can hold multiple values of same type at once

Question B: What is the relationship between length and the valid indexes of an array?
Answer: If the array is of length 5, then set of valid index in array is from 0-4 i.e from 0 to length-1.
Array indexes starts from 0

Question C: Why do we need to pass a size as well as the array to any function/procedure where we want it to use this array?
Answer: Its because when we pass the array we should pass the size as well so that we don’t access element beyond its size.

Question D: For loops are great for working with arrays, but can they be used without an array? Why may you want to do this?
Answer: Yes, they can be used without arrays. They can be used to iterate from a given number to the number. Lets say we want to iterate 10 times. So we can use for loop. Hence for loop can be used without array.

Question E: How could you print out the names in the array starting with the last name and working back to the first name?
Answer: Start the loop from end index of array till the first index

for(int i = arr.length - 1 ; i>=0 ;--i)
print(arr[i])

In this way we can print names from last to the first.



Thanks, let me know if there is any concern. PLEASE UPVOTE

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote