Assignment No. 5
Deadline
Your assignment must be uploaded/submitted on or before 4th April 2003
Uploading instructions
Please view the assignment submission processdocument provided to you by the Virtual University to upload the assignment.
Rules for Marking
It should be clear that your assignment will not get any credit if:
o The assignment is submitted after due date.
o The submitted assignment does not compile or run.
o The assignment is copied.
Objective
The objective of this assignment is to provide an on hand experience of:
o Declaring and manipulating Arrays.
o Declaration and manipulation of the pointers.
o Sorting and searching in an Array.
Assignment
Write a C program that takes integer values from the keyboard, stores them in an array and then sorts (ascending order) that array of 10 elements with the help of pointers. Your program should display the sorted array. Further more the program should search a number entered by the user, from the sorted array and print its index in the array.
Sample Output
Please enter the value for Input [0]: 4
Please enter the value for Input [1]: 12
Please enter the value for Input [2]: 18
Please enter the value for Input [3]: 45
Please enter the value for Input [4]: 23
Please enter the value for Input [5]: 11
Please enter the value for Input [6]: 36
Please enter the value for Input [7]: 54
Please enter the value for Input [8]: 8
Please enter the value for Input [9]: 64
The sorted Array is:
4
8
11
12
18
23
36
45
54
64
Enter the number whose index is to be searched: 54
The number exists at: Input [8]
Note:
If the number entered for the search from the keyboard is not found then a message saying “This number does not exist in this Array” should appear like:
Enter the number whose index is to be searched: 22
This number does not exist in this Array
Important Note
You can improve your assignment by
· making the variable names self–explanatory
· commenting the code properly
· indenting the code properly for making it more understandable
Submit ONLY the .cpp file as your assignment.