Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Implement a C program that reorders the elements of an array of integers such that the new order is in ascending order (i.e. the first number is the smallest). You must have a main function and a swap function.
- The function int main() will declare an array with the values {-13,-51,-78,-91,-42,0}. This array will be passed to the swap function.
- The function void swap() will perform the necessary operations to reorder the elements of the array. Note that because swap is a void function, we cannot return the array back to the main function, meaning we must manipulate memory instead!
- After swap() is finished, have main() print the original array to show the new element order.
- Do not hard code your solution. If we test your code with different array values, we should still get the correct output.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
Knowledge Booster
Similar questions
- Write a function in C++ language which takes two parameters as arguments, the first being an integer array and the second being the size of this integer array, and sorts this integer array in descending order. Write a similar function which takes the same arguments, but sorts the integer array in ascending order. Write a C++ program which takes integer values from user, inserts them into an integer array, uses these two functions to sort the array in ascending and descending order and prints the results on screen. You can take any size of the integer arrayarrow_forwardWrite a program in C write a two-dimension array in the main function that contains different names and grades, then write a function that will ask the user if he wants : Press 1 for print passing students names and grades Press 0 for print failing students names and grades Press 2 for printing all the student's names and grades after that, the function will print what the user wants hint : >= 60 passedarrow_forwardWrite a function in C language that will take a 2D Array of size 3x3 from the user. Your Program should: 1. Prompt the user to enter 2D array of size 3x3. 2. Calculate the sum of all rows. 3. Calculate the sum of all columns 4. Return 1 if the sum of all rows is greater than sum of all columns, 0 otherwise. Your main program should print the result based on the returned values.arrow_forward
- 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…arrow_forwardFor this c++ assignment it must pass the test input as shown belowarrow_forwardIn C++ please and thank you!arrow_forward
- In C++ Create an array of head pointers, statically allocated of size 101 of that type: Now, create a pointer that can point to the first element: Show how to dynamically allocate an array of 101 elements of head pointers: Write the code to initialize each element to NULL: Rewrite the code to initialize each element to NULL using pointer arithmetic:arrow_forwardIn C++, Can you please look at the code below and revise/fix so it will work according to instructions and criteria. Instruction 1) Write a function that copies a 1D array to a 2D array. The function’s prototype is bool copy1DTo2D(int d1[], int size, int d2[][NCOLS], int nrows); where size > 0 NCOLS > 0 nrows > 0 NCOLS is a global constant size = NCOLS * nrows the function returns true if the parameters and constants satisfy these conditions and false otherwise. the relation between 1d array indices and 2d array indices is 2d row index = 1d array index / NCOLS 2d column index = 1d array index modulus operator NCOLS 2) Write a function that copies a 2D array to a 1D array. The function’s prototype is bool copy2DTo1D(int d2[][NCOLS, int nrows, int d1[], int size); where size > 0 NCOLS > 0 nrows > 0 NCOLS is a global constant the function return true if the parameters and constants satisfy these conditions and false otherwise. the relation between 1d array indices and…arrow_forwardwrite in html and scriptarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education