For Loops

i need a hand with this assignment ASAP

use for loop to request for 3 values to be inputted and sorted for the greatest number,and display the greatest value
NB: your program should cater for cases where we have two greater values and when all are of the same value.


1) create a vector or an array
2 a) use a for loop
2 b) ask the user to enter three numbers - cin >> number;
2 c) store the number in the vector or array - numbers.push_back(number);
3 a) write a function to check for greatest value
3 b) return the greatest value

* if you want them sorted, use a sorting algorithm to sort them for example here is a hint

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


void sort(vector<int> numbers&){

   bool fixed = false;

   while(!fixed){
      
      fixed = true;

     for(int i = 0; i < numbers.size()-1; ++i){

          if(numbers.at(i+1) > numbers.at(i)){

               int temp = numbers.at(i);
               numbers.at(i) = numbers.at(i+1);
               numbers(i+1) = temp;
               fixed = false;
         }

     }

  }

}


good luck, attempt it yourself, if you get stuck after a number of attempts post another message.
Topic archived. No new replies allowed.