Programming tasks: Arrays

Here are some short tasks for you to work on in preparation for your quiz next week….

Here is a link with some documentation about Arrays in Visual Basic.

Integer arrays:

  • Write a program that generates an array of 100 random numbers between 1 and 50 (easy)
  • Write a function that returns the average of all of the numbers in an integer array (easy)
  • Write a function that returns the maximum number in an integer array (easy)
  • Write a function that finds the smallest difference between any two neighbouring array elements in an integer array and returns the index of the first of those elements. E.g. in 3 8 1 2 4 7, the smallest difference is between the 1 and the 2, so your function should return the index of the 1, which is 2 (given the array is zero-based) (medium)

String arrays:

  • Write a function that takes two strings s1 and s2 and returns true if one is an anagram of the other (a little harder)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s