Sorting arrays

Ok I got it working, but can someone help me? I need to make it drop the lowest test grade but I have no idea how. Any hints?
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
 #include <iostream>
 #include <iomanip>
 using namespace std;

 //Function prototypes
 void sort(float *, int);
 void prnt(float *, int);

 int main()
 {
 float *testScores, 
 total = 0, 
 average; 

 int numTest, 
 const count=0; 

 cout << "How many test scores are you entering? ";
 cin >> numTest;



 testScores = new float[numTest];

 cout << "Enter the test scores below.\n";
 for (int count = 0; count < numTest; count++)

 {
 cout << "Test Score " << ": ";
 cin >> *(testScores + count);
 }

 for (int count = 0; count < numTest; count++)
 {
 total += testScores[count];
 }

 //Calculate the average test scores
 average = total / numTest;


 cout << "The average of all the test scores is " << setprecision(2) <<
	 fixed << average << endl;

 

 




 //Display the Test Scores in ascending order
 cout << "The test scores in ascending order are: \n";
 sort(testScores, count);
 prnt(testScores, count);


 delete [] testScores;
 testScores = 0; 
 system("PAUSE");
 return 0;
 }

 void sort(float *testScores, int count)
 {
	 int a,b,c;
	 for(int a=0; a<(count-1);a++)
	 {
		b=a;
		b= *(testScores + a);
			for(int i=a+1;i<count;i++)
			{
				if(*(testScores+i)<c)
				{
					i= *(testScores+i);
					b=i;
				}


			}

			*(testScores + b)=*(testScores+a);
			*(testScores +a)= c;
	 }

 }

 void prnt(float *testScores, int count)
 {
	 for(int j=0; j<count; j++)
	 {
		 cout << *(testScores + j) << " ";
		 cout << endl;

	 }



 }
Last edited on
Topic archived. No new replies allowed.