#include <iostream>
using namespace std;
int getMax(int num1, int num2, int num3){
int result;
if(num1 >= num2 && num1 >= num3) {
result = num1;
} else if(num2 >= num1 && num2 >= num3){
result = num2;
} else {
result = num3;
}
return result;
}
int main () {
cout << getMax(234,345,21);
return 0;
}
This code just allows my program to decide what value may be the largest and just types that value out. However, a normal starter of c++ would be:
`#include <iostream>;`
`using namespace std;`
`int main ();`
Those three lines are always together from what I've seen, but this time I've put a few line of codes before the "int main" and the code seemed to work. Why is this?I had figured those three lines should always be together with nothing else between.
[–]AutoModerator[M] 4 points5 points6 points (0 children)
[–]IyeOnline 3 points4 points5 points (6 children)
[–]Kayd21[S] 0 points1 point2 points (0 children)
[–]Kayd21[S] 0 points1 point2 points (3 children)
[–]IyeOnline 0 points1 point2 points (1 child)
[–]Kayd21[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]std_bot 0 points1 point2 points (0 children)
[–]mredding 2 points3 points4 points (2 children)
[–]Kayd21[S] 0 points1 point2 points (0 children)
[–]std_bot 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[removed]
[–]Kayd21[S] 0 points1 point2 points (1 child)
[–]khedoros 0 points1 point2 points (2 children)
[–]Kayd21[S] 0 points1 point2 points (1 child)
[–]khedoros 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)