Question: write a c program that does this: create 2 files that store: + list of number, each per line + -1 will be a marker

write a c program that does this:

create 2 files that store:

+ list of number, each per line

+ -1 will be a marker to end the data

+ all value in the file will >=0 other than the -1 marker

for example:

fileA:

3

2

4

-1 (marker end the list of data)

fileB:

1

2

3

0

-1 ( marker end the list of data)

create 2 functions with 3 variable R A and B:

int combiner (int R[], int A[], int B[] )

int zipper (int R[], int A[], int B[] )

- A & B are passed in; do not modify

- R is the result that is set by the function

- Return the number of items in R when finished ( -1 does not count )

8 12 -1 would be 2 items

- R must have the -1 end marker

specifics on the functions:

int combiner( int R[], int A[], int B[] )

- A and B are in sorted order; you do not need to check or sort

- Combine the values into R so that R contains all values & is sorted

int zipper( int R[], int A[], int B[] )

- A and B can be any lists

- Take from A then B then A then B... until the list is used up.

- If one list is shorter continue to add values from the other.

the program will read 2 files from the user. example fileA and fileB.

./a.out fileA fileB

R combiner: 0 1 2 3 4 -1

R zipper: 3 1 2 2 4 3 0 -1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!