Reference no: EM131381701 
                                                                               
                                       
Assignment- C Programming Basics-
Introduction to Systems Programming
In this assignment you will develop a program to manage several data types, data structures and arrays. Please read the following instructions very carefully and perform the assignment per the instructions.
1.	Login to your virtual machine. Install the wget using the apt-get utility. Refer to the course notes for details on how to perform installation of programs.
2.	From your virtual machine, download the starter source code provided for this assignment. To do this, download the file from canvas to a jump drive. Then from your VM select VM/Removeable devices/your jumpdrive. Copy the file to your home diirectory.
3.	Create a directory for your assignments and copy the file into it. Change into that directory.
% mkdir cmpsc311
% cp assign2-starter.tgz cmpsc311
% cd cmpsc311
% tar xvfz assign2-starter.tgz
Once unpacked, you will have the following starter files in the assign2 directory: Makefile, cmpsc311-S17-assign2.c and a2support.h. The Makefile contains commands to make your program from the source code. cmpsc311-S17-assign2.c contains the main function which reads in values from standard input, as well as calls the functions you are to create as part of this exercise. The a2support.h partially defines functions that you are to implement in the course of this assignment (see below).
4.	You are to complete the cmpsc311-S17-assign2 program. The cmpsc311-S17-assign2 program re- ceives 20 integer values, one per line. The code for reading those values from standard input are provided  in the assignment source code starter file.
5.	You  are to create a new file   a2support.c.  This will include the code for each of the functions defined     in a2support.h. You are also to complete the function definitions in a2support.h. These functions are defined in table 1.
6.	Complete the code in the cmpsc311-S17-assign2.c and a2support.h files. Places where code or dec- larations needs to be added are indicated by ???. See in file comments for hints.  The program shall  perform the following functions in order as implemented within the main() function:
(a)	Read in 20 integer values from the terminal and place them in an array.  Note the code to perform   this step is already provided.
(b)	In the main function, create a second array of float values. The odd values should be calculated by computing the sine function1  on the integer passed in to the same index, and the even values should  be computed by taking the cosine of the indexed value.
(c)	Print out the values of the each array on their line using the showFloats and showIntegers func- tions.
(d)	For each integer,  print out the number of '1' bits in the resulting representation by calling the   function countBits.
iamb598L
1You should use the man utility on the sin() and cos() functions to find out the syntax of this function.
 
(e)	Sort the arrays using the  integerQuickSort and floatQuickSort functions respectively.
(f)	Print the median value of each array using the medianFloat and medianInteger functions, respec- tively.
(g)	Cast each integer to an   unsigned short type and compute a number with bits reversed by calling the reverseBits function.  Print out a binary representation of the each of the numbers by calling the binaryString on two string arrays and printing out the resulting text.
(h)	Print out the sorted arrays again using the  showInts and showFloats functions.
(i)	Print out the CDF plot of the integer array values, where the X axis shows the range of values, from low to high stepping by one, and the Y axis goes from 100% down to 0%, stepping by 5. Note that     a CDF is the cumulative distribution function graph that shows the percentage of values in the array that or equal to the value or lower.
7.	Add comments to all of your files stating what the code is doing.  Fill out the comment function header      for each function you are defining in the code. A sample header you can copy for this purpose is provided for the main function in the code.
8.	The  assignment  starter  package  also  includes  two  sample  inputs  and  outputs  which  you  can  use  to test your program. The test-input.txt file was input used to produce test-output.txt, and the test-input2.txt file was input used to produce test-output2.txt. To test your program with these inputs, run the code an pipe in the input file to the program as follows:
./cmpsc311-s17-assign2 < test-input.txt
Please try to make the output for your program at least approximate that of the test program output.
To turn in:
1.	Create a tarball  file  containing  the  assign2 directory,  source  code  and  build  files  as  completed  above.    Email  the  program  to  [email protected] and  the  section  TA   (listed  on  course  website) by the assignment deadline (11:59pm of the day of the assignment). The tarball should be named LASTNAME-PSUEMAILID-assign2.tgz, where LASTNAME is your last name in all capital letters and PSUEMAILID is your PSU email address without the "@psu.edu". For example, the professor was sub- mitting a homework, he would call the file REGGIO-pdm12-assign2.tgz. Any file that is incorrectly named, has the incorrect directory structure, or has misnamed files, will not be accepted.
2.	Before sending the tarball, test it using the following commands (in a temporary directory - NOT the directory you used to develop the code):
% tar xvzf LASTNAME-PSUEMAILID-assign2.tgz
% cd assign2
% make
... (TEST THE PROGRAM)
Note: Like all assignments in this class you are prohibited from copying any content from the Internet or discussing, sharing ideas, code, configuration, text or anything else or getting help from anyone in or outside       of the class. Consulting online sources is acceptable, but under no circumstances should anything be copied. Failure to abide by this requirement will result dismissal from the class as described in our course syllabus.
| Function | Parameters | Description | 
| showFloats | A reference to the array of floats and a integer length of   the array | This function prints out an array of floats   on a single line. The display width should be the same for each   value (see sample output). The float should only print the first two numbers   to the right of the decimal point. | 
| showIntegers | A reference to the array of integers and   a integer length of the array | This function prints out an array of   integers on a single   line. The display width be the same for each value (see sample output). | 
| medianFloat | This  function  should    receive  a reference   to an array of floats and the array length. | The function should return the median float   value of the array passed. | 
| medianInteger | This should receive a reference to an array   of integers and the array length | The    function  should  return    the  median integer value of the array passed. | 
| countBits | This should receive an integer of the number to count bits   from | The function should return the number of   nonzero bits in   the number. Note that any negative sign should be ignore for the purposes of   counting bits. | 
| reverseBits | This  should  receive    a unsigned short   integer of the number to re- verse | The function should return the number whose   bits are reversed, i.e., the top bit of the original num- ber is   the bottom bit of the returned number, the second from the top bit of the   original number is the second to the bottom bit of the returned num- ber. | 
| binaryString | This should receive a pointer to a string, a   length and a number to convert to binary | This function should fill the text string   with a binary representation of the number suitable for printing.   If the string is  too  long,    just  print  as many digits as is possible (don't forget   to NULL terminate the string). | 
| floatQuickSort | This    function  should  receive    a reference to the    float  array  and the index of a left and right ele- ment   to sort. | The recursive function should sort the   values   in the array using a quick sort, from highest to low- est. You   can use the algorithm listed on the corre- sponding Wikipedia page as   inspiration. | 
| integerQuickSort | This    function  should  receive    a reference to the integer array and the index of a left and   right ele- ment to sort | The function should sort the values in   the array using a quick sortfrom lowest to highest.  You   can use the algorithm listed on the   corresponding Wikipedia page as inspiration. | 
| showCDF | The function should receive both an   integer array, as well as the length. | Print out the CDF plot of the array values,   where the X axis shows the range of values, from low to high   stepping by one, and the Y axis goes from 100% down to 0%, stepping by   5.  Note that a  CDF is the cumulative distribution function   graph that shows the percentage of values in the array  that or equal to the value or lower. | 
Table 1: Functions to define and implement.
Attachment:- Assign-starter.tgz