int Highest(int num1, int num2, int num3, int num4);
int main()
{
int num1,
num2,
num3,
num4;
cout << "Enter any 4 numbers and I will tell you the highest and the lowest" << endl;
cin >> num1;
cin >> num2;
cin >> num3;
cin >> num4;
Highest(num1, num2, num3, num4);
return 0;
}
int Highest(int num1,int num2,int num3,int num4)
{
if (num1 > bigNum)
bigNum == num1;
if (num2 > bigNum)
bigNum == num2;
if (num3 > bigNum)
bigNum == num3;
if (num4 > bigNum)
bigNum == num4;
cout << "The biggest number is " << bigNum << endl;
return bigNum;
}
#include <iostream>
#include <algorithm>
// return the highest of a, b, c, d
int highest( int a, int b, int c, int d )
{
int big_num = a ;
if( big_num < b ) big_num = b ; // =, not ==
if( big_num < c ) big_num = c ;
if( big_num < d ) big_num = d ;
return big_num ;
}
int main()
{
int a, b, c, d ;
std::cout << "enter four numbers: " ;
std::cin >> a >> b >> c >> d ;
constint highest_number = highest( a, b, c, d ) ;
std::cout << "the highest number is: " << highest_number << '\n' ;
// verify that we got the correct result by checking with std::max in <algorithm>
// http://en.cppreference.com/w/cpp/algorithm/max
std::cout << "std::max( {a,b,c,d} ) returned: " << std::max( {a,b,c,d} ) << '\n' ;
}