this is a bonus challenge Create a function that will return the smallest of three integers entered by the user. Write a program to test it. (Hint: a function argument [or parameter] can be another function call)
this is my code:
#include <iostream>
#include <stdlib.h>
using namespace std;
main()
{
int num1, num2, num3;
using std::cout;
using std::min;
using std::max;
cout << max( max( num1, num2 ), num3 );
cout << min( min( num1, num2 ), num3 );
if ((num1 > num2)&&(num1 > num3))
{
cout<< "Number one is the Largest which is: " << num1 << endl;
}
if ((num2 > num1)&&(num2 > num3))
{
cout<< "Number two is the largest which is: " << num2 << endl;
}
if ((num3 > num1)&&(num3 > num2))
{
cout<< "Number three is the largest which is: " << num3 << endl;
}
if ((num2 < num1)&&(num2 < num3))
{
cout<< "Number two is the smallest which is: " << num2 << endl;
}
if ((num3 < num1)&&(num3 < num2))
{
cout << "Number three is the smallest which is: " << num3 << endl;
}
if ((num1<num2)&&(num1<num3))
{
cout<< "Number one is the smallest which is: "<<num1<<endl;
}
system("pause");
return 0;
}
Im not sure what is wrong with the code. the output is wrong please help
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <algorithm>
usingnamespace std;
int main()
{
int num1 = 3, num2 = 6, num3 = 1;
using std::cout;
using std::min;
using std::max;
cout << max(max(num1, num2), num3);
cout << min(min(num1, num2), num3);
if ((num1 > num2) && (num1 > num3))
{
cout << "Number one is the Largest which is: " << num1 << endl;
}
if ((num2 > num1) && (num2 > num3))
{
cout << "Number two is the largest which is: " << num2 << endl;
}
if ((num3 > num1) && (num3 > num2))
{
cout << "Number three is the largest which is: " << num3 << endl;
}
if ((num2 < num1) && (num2 < num3))
{
cout << "Number two is the smallest which is: " << num2 << endl;
}
if ((num3 < num1) && (num3 < num2))
{
cout << "Number three is the smallest which is: " << num3 << endl;
}
if ((num1 < num2) && (num1 < num3))
{
cout << "Number one is the smallest which is: " << num1 << endl;
}
system("pause");
return 0;
}