View the step-by-step solution to:

Write a C program Gen.c that generates a ordered sequence of 20 random numbers within a range of 1000 to 9999.

Write a C program Gen.c that generates a ordered sequence
of 20 random numbers within a range of 1000 to 9999. The
program is invoked by a command line

% gen datfile1

In the above line, gen is the executable, datfile1 is the argument to the execution of gen. It specifies the name of the output file for the 20 random numbers.
To make Gen.c possible, your main() program should accept arguments like

#include <stdio.h>
void main (int argc, char *argv[])
{
char *fname = argv[1];
....
fp = fopen(fname,"w");
....

Sign up to view the entire interaction

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question