C-How to program. What should I add?
-
Write a C program that includes the following data into a one-dimensional array: 12 1 2 72 16 11 92 63 99 59 The main program should allow the user to enter one of six choices: Choice One: Search for a particular number using the Sequential Search method. If the number is found in the array, print “The number was found in the array using the Sequential Search Method”, along with the array number. If the number cannot be found in the array, print “The number was not found in the array using the Sequential Search Method”, along with the number being searched for. Choice Two: Search for a particular number using the Binary Search Method. If the number is found in the array, print “The number was found in the array using the Binary Search Method”, along with the array number. If the number cannot be found in the array, print “The number was not found in the array using the Binary Search Method”, along with the number being searched for. Remember that with the Binary Search Method, the array must be in sorted order prior to using the Binary Search Method. Choice Three: Sort the one-dimensional array using the Bubble Sort Method. Show the unsorted array, as well as the sorted array results. Choice Four: Sort the one-dimensional array using the Selection Sort Method. Show the unsorted array, as well as the sorted array results. Choice Five: Sort the one-dimensional array using the Insertion Sort Method. Show the unsorted array, as well as the sorted array results . Choice Six: End Program Run Be sure that your program resets the array back to its original values so that you can test all of the sorting functions in one programming run. ______________________________________... *** I did choice # 3. Bubble Sort Method. My results are below. What should I add or is there an easier choice? ______________________________________... /*JWoessner.h*/ #include <stdafx.h> #include <stdio.h> #define SIZE 10 int main( void ) { int a[ SIZE ] = { 12, 1, 2, 72, 16, 11, 92, 63, 99, 59 }; int pass; int i; int hold; printf( "Data items in original order\n" ); for ( i = 0; i <= SIZE - 1; i++ ) printf( "%4d", a[ i ] ); } /*BUBBLE SORT*/ for ( pass = 1; pass <= SIZE - 1; pass++ ){ for ( i = 0; i <= SIZE - 2; i++ ){ if ( a[ i ] > a[ i + 1 ] ){ hold = a[ i ]; a[ i ] = a[ i + 1 ]; a[ i + 1 ] = hold; } } } printf( "\nData items in ascending order\n" ); for ( i = 0; i <= SIZE - 1; i++ ){ printf( "%4d", a[ i ] ); { printf( "\n" ); {
-
Answer:
Um. . . . wouldn't you have to add all of the choices? "The main program should allow the user to enter one of six choices:" your considered to be the programmer not the user. . . So in this case. . . you would have to add all of them. . . and prompt to user to see what how he wants to sort the array/ search.
JLC at Yahoo! Answers Visit the source
Other answers
Um. . . . wouldn't you have to add all of the choices? "The main program should allow the user to enter one of six choices:" your considered to be the programmer not the user. . . So in this case. . . you would have to add all of them. . . and prompt to user to see what how he wants to sort the array/ search.
wingles_...
Related Q & A:
- What can I add to my website?Best solution by Stack Overflow
- What can i add in constructors in PHP?Best solution by Stack Overflow
- I want to add my personal photos. how can i add it.
- What should I add for a professional reference on my job app?Best solution by Yahoo! Answers
- What can i do to fix my P.C?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.