Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program needs to be coded in C. This program takes exactly 7 integer command line parameters. It should check for the correct number of

This program needs to be coded in C. This program takes exactly 7 integer command line parameters. It should check for the correct number of command line parameters, assume that all are integers, print a line containing your name and a line containing the values of the parameters. The output should be in the form: Assignment 1 program was written by FirstName LastName inputs: 0 2 4 6 7 8 9 If the number of parameters is incorrect, print an appropriate message and exit. The main program should then create two arrays of characters that will be large enough to hold the character string you will be creating. The maximum size of any of the strings will be the sum of the last six command line parameters. If an error occurs in creating these arrays, exit the program with an appropriate error message. Otherwise call two functions, one to create the strings and one to print them out as follows: void part0(char *s1, char *s2); void display(char *heading, char *s1, char *s2); These two functions should be put in the file pslibrary.c. Put prototypes for these in pslibrary.h and have assign1-0.c include pslibrary.h. For this part of the assignment use the heading: "Part 0 ". The part0 function will just copy the following strings into the two parameters: RRwwwwwRRRRRRRRR and rrRRRRwwwwwwwwrrRRRRRRR and return. Note that part0ignores all of the command line parameters. Call the program with parameters that are large enough so that the program will allocate enough space for these strings. The display function that you write for this part will be used in the next part of this assignment and in future assignments.The display function prints only to standard out and does the following:

Print a blank line to standard output.

Print the heading.

Print the first string on its own line. The first string is the second parameter to display. You may assume that the heading ends with a new line so that the first string is printed at the start of a line. After printing this string, print a newline so that next string starts directly below it.

Print the second string on its own line. After writing the string to standard output, output a newline.

Print 4 numeric values all on a single line, separating consecutive values with a single blank.

The number of 'r' characters in the second parameter.

The number of 'r' characters in the third parameter.

The average of these two number, displayed with one decimal place.

A floating point number number displayed with 5 decimal places. This values is the total number of 'R' characters in the second and third parameters divided by the length of the longer of these two parameters.

Run Part 0 and save the output generated as output-part0.txt Note: When you run Part 0, make sure that the command line parameters are large enough so that there is enough room for the strings.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago

Question

What are the role of supervisors ?

Answered: 1 week ago

Question

Define the goals of persuasive speaking

Answered: 1 week ago