repl.it
@SylvianBryan/

Array and Sorting - Ready to turn in for a grade

C

No description

fork
loading
Files
  • main.c
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
N#: N01422856
Name:  Sylvian Bryan 
Title:  Buble Sort Numeric 
Description:  This program execute Sort Utilized Bubble.  
Date: 4/18/2019 
*/

#include <stdio.h>

int main() {

int eleArray; // Entry Captured
int start=0;// Zero Reference
int smaNum;// Used for arrangemnt 
int temp; // Temp hold Number
int numArray; //Entered value 
int bucket;//Swap numbers

//Prompts and Capture
printf("\n\n\nEnter the number of elements to be in array: ");
scanf("%d", &numArray);

//Gen. Array
int genArray [numArray=numArray-1];//Array generate cell number by user ended 

//Output Data
printf("\nElements of array are: ");{
for (int start;start<=numArray;++start)

//Insert entered number into index chronological order "increase" -Swap. 
  scanf("%d", &genArray [start]);{
    for (start=0; start<numArray;start++){
      for (bucket=0; bucket<numArray; bucket++){
      if (genArray[bucket]>genArray [bucket+1]) 
      {
      temp=genArray[bucket];
      genArray[bucket] = genArray[bucket+1];// Arrange numbers....
      genArray[bucket+1] = temp;
      }
    }
  }
//Output organized data 
printf("\nThe smallest number is: %d\n\n", genArray[bucket-numArray]);// prints sm val.
  printf("The largest and second largest number is: %d & %d\n\n", genArray[bucket], genArray [bucket-1]);// prints LR and 2nd LR Val.
  printf("Sorted array is: "); 
  for (bucket=0; bucket<numArray+1; ++bucket){
  printf(" %d",  genArray [bucket]);// Prints index 
  } 

}
}

printf("\n\n\n***After Code 40 hrs., Proudly Sort Any Number!***");// Closure.

return 0;
}