Finding the MaxSum of two numbers

Hello! I was wondering if anyone can suggest a solution to my problem.

The main objective of this program is to find the maximum sum of 2 integers from 3 user inputs. But it's not complete.

when i'm inputting three numbers, let's say: 1, 2, 3 it works fine. it recognises 3 and 2 as the largest and adds them up with no problem.

but when i enter, 3, 2, 1, it's adding 3 and 1 as the largest which is obviously incorrect.

Any suggestions and help would be greatly appreciated.


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

#include<iostream>

using namespace std;

int main()

{
    int num1;
    int num2;
    int num3;
    int high1;
    int high2;
    int maxSum;
    
    cout << "\n                       Hello there !\n\nThis Program will find the Maximum Sum of the \n" "\t" "TWO LARGEST Numbers !\n\n";
    cout << "--- Enter 3 numbers --- \n" << endl;
    cout << "Please enter your 1st number: ";
    cin >> num1;
    
    cout << "Please enter your 2nd number: ";
    cin >> num2;
    
    cout << "Please enter your 3rd number: ";
    cin >> num3;
    
  
  {
   
   if (num1 < num2)
    
    {
            high1 = num2;
            high2 = num3;
            maxSum = num2 + num3;
            
    }
    
    
    else if (num2 < num1)
    
    {
            high1 = num1;
            high2 = num3;
            maxSum = num1 + num3;
            
    }
            
    else if (num3 < num1)
    
    {
            high1 = num1;
            high2 = num2;
            maxSum = num1 + num2;
         
    }
    
  
   
     cout << "\n";
        
         
}

     cout << "The Maximum Sum of " <<high1;
     cout << " and " <<high2;
     cout << " is " << maxSum << endl;
     cout << "\n";
     cout << "Thank you for using this program !\n\n";             
    
   
    
    
    
    
     system("pause");
     return 0;


}

Given three integers A, B, and C, write in English how you -- a human -- would figure out which one is the largest
and which one is the second largest. Post that here, then we'll work on translating to actual code.
Topic archived. No new replies allowed.