Develop a program to manage several data types and arrays

Assignment Help C/C++ Programming
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

Reference no: EM131381701

Questions Cloud

Calculate the modulus of elasticity : A 3-in.-wide by 1 2 -in.-thick board is bent to a radius of curvature of 62 in. by a bending moment of 700 lb-in. Calculate the modulus of elasticity.
Calculate the maximum deflection of the shaft : A solid, round simply supported steel shaft has a diameter of 38 mm and a span length of 800 mm. The shaft supports a concentrated load of 3 kN at midspan. Calculate the maximum deflection of the shaft.
Enter the weight of a package : Write a program that asks the user to enter the weight of a package and then displays the shipping charges.
Calculate the maximum deflection of the shaft : A solid, round simply supported steel shaft has a diameter of 38 mm and a span length of 800 mm. The shaft supports a concentrated load of 3 kN at midspan. Calculate the maximum deflection of the shaft.
Develop a program to manage several data types and arrays : CMPSC311- 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.
Is the given beam satisfactory : Compute the maximum deflection of a 10-in.-by-14-in. simply supported solid rectangular redwood (S4S) beam.
Conduct a short interview-by phone : JUS 261:Conduct a short interview-by phone, in person or by email-of a court clerk, assistant clerk, docketing clerk, administrative assistant, bailiff, or other staff member of a court near where you live or work. Identify the individual and his..
Floating point representation : Assuming that you are required to make an 8 bit floating point representation, with a 3 bit exponent using excess-3 notation and a 4 bit mantissa using normalized notation. How would the number 0.5 be stored in the byte?
Criminal arrest process arrest through incarceration : 1. Explain the criminal arrest process from arrest through incarceration, and is it the same process for all crimes and criminals? 2. How does the internet facilitate international criminal activity and complicate evidence gathering?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd