Question: This is C programming language problem. I use DEV C++. Please give me this questions answer with output screenshort. Thanks Problem: Create a C program
This is C programming language problem. I use DEV C++. Please give me this questions answer with output screenshort. Thanks
Problem:
Create a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an increasing or decreasing order based on the user's choice. The pseudo code for the bubble sort algorithm is shown below.
function bubblesort( A : list of numbers )
for each i=length(A)-1 to 0
for each j=1 to i
if A[j-1] > A[j]
swap( A[j-1], A[j] )
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 100 numbers will be entered. You can also assume the user will enter 0 to mark the end of the input.
Program Specification:
1. Have three functions besides main:
a. one that accepts the sequence of numbers
b. 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
c. a swap function to be called from the sorting function
2. The main function prints the sorted sequence of numbers
3. The program ignores inputs that are negative numbers.
4. You can use the strcmp c string comparison function in this program; strcmp takes two strings as input and returns 0 if the two strings are equal or a non-zero value if the input strings are not equal.
Sample Run of the Program:
C:\> sort
Enter sort order: up
Enter a sequence of numbers: 10 2 1 3 40 20 0
1 2 3 10 20 40
Grading:
Correctness: 20 (includes tests as well as code examination)
Proper use of C features,
Following specs: 12
Readability and documentation: 8 (split up as below)
| Criteria | Points |
| Program function at the top | 1 |
| Meaningful documentation before each function | 3 |
| Proper use of space to separate tokens | 1 |
| Indentation and alignment | 2 |
| Naming of variables | 1 |
Submission: Submit the C program source code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
