SPL Review (Problem Set)
SPL Review (Problem Set)
1. Write a program that will take N numbers as inputs and compute their average.
(Restriction: Without using any array)
Sample input
N Sample output
numbers
7
39.57
4 256 2 4 3 3 5
2. Write a program that will run and show keyboard inputs until the user types an ’A’ at
the keyboard.
4. Write a program that prints the number of occurrences of each unique elements of an
array.
6.
Write a code that will take n integer numbers into an array, and then reverse all the integers
within that array. Finally print them all from 0 index to last valid index.
The code should contain
(i) A function reverse_array that takes as input an array and reverses the array
inside the function
(ii) A function print_array that takes as input an array and prints it
(iii) A main method that uses the functions reverse_array and print_array to
produce the output
8.
Write a Program that will take as input a string, and toggle cases of all the letters.
Sample input Sample output
SPL Laboratory spl lABORATORY
United International University uNITED iNTERNATIONAL uNIVERSITY
Review Structure:
9.
Write a program to take as input the name, height in cm and age of n employees, and
sorts it according to height in descending order. If two employees have the same height then
sorts according to age in descending order. Print the employees in the sorted order.
10. Write a program to take as input an array of N names, an array of N ids and an array
of N salaries where the name, id, and salary of the th index belongs to the same
person. Store them in a structure and sort them according to salaries (ascending) and
then by ids (ascending). Print the person in the sorted order.