Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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 reggio@psu.edu 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

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92191525
  • Price:- $100

Priced at Now at $100, Verified Solution

Have any Question?


Related Questions in C/C++

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As