Q1. Pupils' heights
The health visitor at a school is going to evaluate the heights of all pupils. For each class she makes a statistics giving the number of pupils of each height and the average height.
Create a C++ program which assists the health visitor making the statistics.
Example: In a class with 20 pupils the heights of the individual pupils, in centimetres, are:
175, 167, 160, 164, 183, 187, 188, 179, 176, 175,
169, 175, 176, 178, 165, 160, 173, 165, 187, 178
The program must read in all the numbers and make a table like this:
Height number of pupils
160 2
164 1
165 2
167 1
... ...
... ...
188 1 average height 174.0 Maximum Number of Students lies between 173 and 179
Q2. Find the nth smallest number in an unsorted array of numbers. Write a C++ Program.
Hint [14 are 3rd smallest number is this array {25, 14, 10, 5, 50, 30} Hint: First sort the array
Q3. Write a C++ program that finds square root of number?
Q4. Set theory: Write C++ programs that declare/initialize two integer arrays A and B of size 10. You program takes input values from user. Initialize an integer array U of size 50 with first fifty positive integers. Your program provides following functionality to user.
Press N or n for A intersection B
Press U or u for A Union B
Press / for A / B
Press \ for B / A
Press A or a for A’s Complement
Press B or b for B’s Complement
Press D to prove De Morgan’s Law
You program continues till user desire to quit. Output of your programs must be in set representations that is, A union B = {2, 4, 34, 20} OR A’s Complement = {45, 34, 22}. In case of De Morgan’s Law compute intersection or Union first and then apply complement.