Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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
Check Mark
Knowledge Booster
Background pattern image
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
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education