Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program that uses command line arguments to have the user input the command as follows at the prompt ($ signifies the prompt):

Write a C program that uses command line arguments to have the user input the command as follows at the prompt ($ signifies the prompt):

$ my_prog 4 input.txt output.txt

The first argument my_prog is the name of the executable, 4 is the number of floating point numbers in the file called input.txt (this is the third argument and can be any integer) and the 4th argument is the filename output.txt in which you will write the results.

The program is similar to what you did in the previous class exercise. Your program opens the file input.txt and reads the float numbers from it into an array. The size of the array is the second argument (4 as seen above or whatever you choose as long as you have that many numbers in the input file). So, your program will have to first dynamically allocate an array of this size and then read the numbers from the input file input.txt into this array. The program will then print the sum, average, product, smallest and largest in the same format as you did in the previous class exercise. The difference is that the output will be send to the output file output.txt and not to the console like you did in the previous class exercise. Please verify after you run your program that the output.txt is created with the correct output.

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago