Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Description: Write a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an ascending or descending order based
Problem Description: Write a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an ascending or descending order based on the user's input. The pseudo code for the bubble sort algorithm is below function bubblesort( N : list of numbers) for each i=length(N)-1 to 0 for each j=1 to i if NI-1]>NDI swap( Ni-1], NO]) end if end for end for end function The program prompts the user for the sequence of numbers to be sorted followed by the sort order. You can assume a maximum of 50 numbers will be entered. You can also assume the user will enter 0 to mark the end of the input Program Specification: . Have three functions besides main o one that accepts the sequence of numbers o one that sorts the sequence of numbers, this function should take three parameters: the sequence of numbers as an array, size of the sequence, and the sorting order o a swap function to be called from the sorting function . The main function prints the sorted sequence of numbers * The program ignores inputs that are negative numbers Sample output of the Program: C:l> sort Enter sort order: ascending Enter a sequence of numbers: 10 2 1 3 40 20 0 1 2 3 10 20 40
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started