i arranged the sequence for the program and the teacher doesnt allow arrange sequence and then running a for loop to run it , she insisted on bubblesort . therefore anyone out there pls change my program for me , by the way i am using turbo C
Months S$
Jan 78
Feb 67
March 82
April 55
May 73
June 69
July 76
August 81
September 59
October 64
November 77
December 61
Write a sending and receiving programs such that when ‘1’ is pressed at the sending PC, the receiving PC will receive it and display the phone bills in descending order and in odd months only . when ‘2’ is pressed at the sending pc , the receiving PC will display the phone bills in ascending order and in even months only . When esc key is pressed at both PC, both programs will quit.
Use array and pointer to write both programs. The communication parameters are 7 bits character. 1 stop bit, even parity, 9600 baud rate, com 2 port.
The my presented function must be situated on the top of your source file(or you can create new header file and add function to one). And then where you need to sort you just call it;
bubbleSort(myData, sizeOfMeData);
where:
myData is your array that should be sorted
sizeOfMeData is size of your array(quantity of elements in myData
I can argue with you too, because our algorithms are different.
Just let me say that I would rather use your algorithm than mine, I'm just saying that your sort isn't a bubble sort.
Bubble sort compares every element with the element that is directly beside it (which mine does), yours does not. Your compares the element at position i with an increasingly farther element j.
It chooses element i, (which is fixed) for ever iteration over the loop for j. Your algorithm is a Selection Sort, however Selection Sort typically saves the smallest value over the iteration and
does the swap at the end of the nested loop instead of every time it encounters a smaller value.