Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void sortAscendingOrder(int*, int );
- void calculatesAverage(int*,int);
- int main()
- {
- int* array = nullptr;
- int input;
- std::cout << "Enter the number of testscores you want to enter." <<std::endl;
- std::cin >> input;
- array = new int[input];
- for(int count =0; count < input; count++)
- {
- std::cout << "Enter the test score" << (count +1) <<":" <<std::endl;
- std::cin >> array[count];
- while(array[count] < 0)
- {
- std::cout <<"You enter a negative number. Please enter a postive number." <<std::endl;
- std::cin >> array[count];
- }
- }
- sortAscendingOrder(array,input);
- for(int count =0; count < input;count++)
- {
- std::cout << "\n" << *(array+count);
- std::cout << std::endl;
- }
- calculatesAverage(array,input);
- return 0;
- }
- void sortAscendingOrder(int* input,int size)
- {
- int startScan,miniIndex,miniValue;
- for(startScan =0; startScan < (size-1);startScan++)
- {
- miniIndex = startScan;
- miniValue = input[startScan];
- for(int index = startScan+1;index<size;index++)
- {
- if(input[index] < miniValue)
- {
- miniValue = input[index];
- miniIndex = index;
- }
- }
- input[miniIndex]=input[startScan];
- input[startScan]=miniValue;
- }
- }
- void calculatesAverage(int* input, int size)
- {
- int total = 0;
- int average =0;
- int lowest= input[0];
- for(int count = 0; count < size; count++)
- {
- total += input[count];
- }
- total-=lowest;
- std::cout << "Lowest test score" <<lowest << "is dropped";
- average =total/(size-1);
- std::cout << "Your average is" << average;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement