Help with writing a program a C program implements a bubble sort algorith on an array of integers, and use command line paramameters to populate an array with data. The program should follow below guidelines if possible: If there are no command-line arguments at all when the program is run, the program should print out instructions on its use (a "usage message"). There should be one common usage message (consider a method/function for printing the usage message) for any type of usage error. The program will accept an A or D as the second command line argument (after the program name). This letter will tell you whether the bubble sort should sort in ascending or descending fashion. Anything other than A or D in that position should display the usage message and terminate the program. The program will be able to accept up to 32 numbers (integers) on the command line. If there are more than 32 numbers on the command line, or no numbers at all, the program should print out the usage message and exit with a non-zero value from main. This means 32 values not including the program name (argv[0]) and sort type. You may assume that the command line arguments (except for the sort type) are all integers. Sort the numbers using the bubble sort algorithm. Do not use a global array to hold the integers; use a locally-defined array in main and pass the array to the sorting function along with the type of sort (ascending or descending). Print out the sorted numbers, one per line. Your bubble sort function must be in its own separate file. The main()function should be in a file called main.c, along with supporting functions (like for printing a usage message). This program must be written in C (not C++). Note that if you're compiling on an OS, use the gcccommand, not g++. Note also that since your program is in C, your source files should have a .cextension, not .cpp or .cxx.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Help with writing a program a C program implements a bubble sort algorith on an array of integers, and use command line paramameters to populate an array with data.

The program should follow below guidelines if possible:

  1. If there are no command-line arguments at all when the program is run, the program should print out instructions on its use (a "usage message"). There should be one common usage message (consider a method/function for printing the usage message) for any type of usage error.
  2. The program will accept an A or D as the second command line argument (after the program name). This letter will tell you whether the bubble sort should sort in ascending or descending fashion. Anything other than A or D in that position should display the usage message and terminate the program.
  3. The program will be able to accept up to 32 numbers (integers) on the command line.
  4. If there are more than 32 numbers on the command line, or no numbers at all, the program should print out the usage message and exit with a non-zero value from main. This means 32 values not including the program name (argv[0]) and sort type.
  5. You may assume that the command line arguments (except for the sort type) are all integers.
  6. Sort the numbers using the bubble sort algorithm. Do not use a global array to hold the integers; use a locally-defined array in main and pass the array to the sorting function along with the type of sort (ascending or descending).
  7. Print out the sorted numbers, one per line.
  8. Your bubble sort function must be in its own separate file. The main()function should be in a file called main.c, along with supporting functions (like for printing a usage message).
  9. This program must be written in C (not C++). Note that if you're compiling on an OS, use the gcccommand, not g++. Note also that since your program is in C, your source files should have a .cextension, not .cpp or .cxx.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education