help with simple function

does anyone know how to write a simple function that will take 3 ints and find the sum of the higher 2?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
this is what i got so far
int findsum(int a,int b,int c)// will find the highest int and return it to our main program
        {
    int max,max2;// this sets our local variable max
  // next we will find the larger of our first 2 variables
   if( a>=b)
    {    max=a;
       
}   else
        max=b;
        
   // next we will take our local variable which holds max from the first two
   //variables and compare it to our third to get the larger
   if (max<c)
        max=c;


i have no idea how to get the second highest number and add it to max
anyone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void swap(int& a, int& b)
{
  int temp = a;
  b = a;
  a = temp;
}

int findsum(int a, int b, int c)
{
  if (a < b) swap(a, b);
  if (b < c) swap(a, c);

  return a+b;
}
Topic archived. No new replies allowed.