Arrays: Exercises
Single Dimensional Array
1:
Write a program that asks the user to enter 5 numbers, then asks him to enter another number to
search for. The program should print whether the number exists in the array or not.
2:
Write a program that asks the user to enter 4 names, then prints the longest name among them.
3:
Write a program that:
▪ Asks the user to enter 5 numbers
▪ Stores them in an array
▪ Counts and prints the number of even values
Two Dimensional Array
1:
Write a program that:
▪ Declares a 2×2 two-dimensional array.
▪ Asks the user to enter the elements of the array.
▪ Prints all the elements of the array.
2:
Write a program that:
▪ Declares a 2×2 two-dimensional array.
▪ Asks the user to enter the elements of the array.
▪ Calculates and prints the sum of all elements in the array