### A little if equation program

! After posting this i realized this is a forum for problems, where can i put code, that not necessarily has problems? !

Hello, here is a program that is able to check 4 integers and tell if they match.
I am pretty sure there are lot of ways writing this easier but my point was to use the if, else if and else along with an equation check.

Any criticism, any at all, is appreciated. So what do you think?

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798`` ``````#include using namespace std; int main() { int a, b, c, d; cout << "Choose 4 numbers and I will tell you which ones is the highest." << endl << "Type in 4 numbers with space between: "; cin >> a; cin >> b; cin >> c; cin >> d; // Checks if all the numbers match. if (a==b && b==c && c==d ) cout << "All the numbers match, all being " << d; // Checks if A is the highest. else if (a>b && a>c && a>d) cout << "The first number is the highest, being " << a; // Checks if b is the highest. else if (b>a && b>c && b>d) cout << "The second number is the highest, being " << b; // Checks if c is the highest. else if (c>a && c>b && c>d) cout << "The third number is the highest, being " << c; // Checks if c is the highest. else if (d>a && d>b && d>c) cout << "The last number is the highest, being " << d; // Checks if two of the numbers matches and being the highest else if (a>c && a>d && a==b) // a b * * cout << "The first and the second number are the highest, being " << a; else if (a>b && a>d && a==c) // a * c * cout << "The first and the third number are the highest, being " << a; else if (a>b && a>c && a==d) // a * * d cout << "The first and the last number are the highest, being " << a; else if (b>a && b>d && b==c) // * b c * cout << "The second and third number are the highest, being " << b; else if (b>a && b>c && b==d) // * b * d cout << "The second and the last number are the highest, being " << b; else if (c>a && c>b && c==d) // * * c d cout << "The third and the last number are the highest, being " << c; // Checks if 3 numbers match each other else if (a>d && a==b && a==c) // a b c * cout << "The first three numbers are the highest, being " << a; else if (a>b && a==c && a==d) // a * c d cout << "The first and the two last numbers are the highest, being " << a; else if (a>c && a==b && a==d) // a b * d cout << "The first and the two last numbers are the highest, being " << a; else cout << "The three last numbers are the highest, being " << c; cout << "."; return 0; }``````

Last edited on
Cool and yeah there is a section for these kind of posts, the lounge. check the left navigation bar of this site.

Thanks,
Aceix.
Thanks for the reply =) I will post future (complete code programs there) =)
Topic archived. No new replies allowed.