$30
Assignment 4
CISC 220
Administrative Notes:
All of the administrative notes from previous assignments apply to this assignment as well. I will
just summarize the main points here and you can refer back to the previous assignments
instructions for more details:
Your program should work in CASLab Linux servers.
No group work allowed.
Hand in your file to OnQ in the “Assignment 4” Dropbox area.
Follow instructions carefully or you may lose points.
There is a 24-hour “grace period” after the official deadline for each assignment;
submissions made within this period lose 10% but are still accepted.
Deadline:
The deadline for this assignment is Monday, November 12 at 8 a.m. The grace period lasts
until Tuesday, November 13, 2018 at 8 a.m.
Required Program:
This is your pointers and arrays assignment and your task is to write a fairly simple C program. It
can be done with the features of C we've discussed in the “Pointer and arrays” topic. The
program requires to generate a 7 random number, save them in an array, then sort them out in
ascending order. You may use what we have covered and explained in the class.
The object of your program is to demonstrate the skills you have learned in C programming.
Your program will work as follows when you it is executed:
1- It generates 7 random numbers between 1 and 99.
2- Save these 7 numbers in an array and display it on the screen.
3- Sort the array by using swapping function that use pointers and also by using a function
that pass the numbers by reference (not by value).
4- The sorting is carried out in iteration. The number of iteration of swapping is looped until
the array is sorted. Print out the result of each iteration on the screen.
5- Stop when the array is sorted and print the final sorted array
6- Quit
For example: Assume the program generates the following numbers in MyMyArray [ ]:
5 77 1 47 14 88 10
Then, in first loop the program compare MyArray[0] and MyArray[1] and swap them if
necessary, so that MyArray[0] would be less than or equal MyArray[1]. Then compare
MyArray[1] and MyArray[2] and swap them, if necessary. Then do MyArray[2] and MyArray[3]
…. until comparing MyArray[5] and MyArray[6] the last two elements then stop. Print the
MyArray [ ]. And proceed to the next iteration. So the same sorting, two elements at a time, are
sorted. Print MyArray [ ] at the end of second iteration. And keep looping to next iteration until
MyArray [ ] is sorted completely. At this point print the sorted array and stop.
For our example above, your output should be as follows:
5 77 1 47 14 88 10 Randomly generated Array
5 1 47 14 77 10 88 Iteration No. 1
1 5 14 47 10 77 88 Iteration No. 2
1 5 14 10 47 77 88 Iteration No. 3
1 5 10 14 47 77 88 Iteration No. 4
1 5 10 14 47 77 88 Sorted Final Array
You have to use:
1- Random function to generate numbers between 1 and 99 and save them in MyArray [ ].
2- Swapping function that uses pointers.
3- Comparing function that passes two numbers by Reference to be swapped by the
Swapping function, if necessary.
Your assignment worth 20 points.
More Requirements:
Your program must be in a single file called CISC220-Assn4.XXXX.c
the XXXX represent your last four digits of your students ID.
Marking Scheme:
Correct random function that generates an array of 7 numbers of values between 1 – 99: 2
Correct swapping function that uses pointers: 4
Comparing function that passes two arguments by reference: 4
While or For loop that does the sorting iteration to produce the sorted array: 6
The output has to be aligned as shown above: 2
Clear and organized Coding style: 2
Total: 20
If you do not follow the assignment requirements -- especially if you deviate from them in a way
that costs us time while marking -- you will lose administrative points even if your program
works correctly. So please read the directions carefully.
Possible Penalties:
10% if you hand in during the late period (24 hours after the deadline).
10-20% if there are administrative issues that cause the graders extra time.
Style:
Use tabs and proper indentation to organize your program. Use common naming conventions we
have been using in our examples at classes.