You could perhaps use the ternary operator?
int foo(int a, int b, int c, int d, int e)
{
int min = a;
min = min > b ? b : min;
min = min > c ? c : min;
min = min > d ? d : min;
min = min > e ? e : min;
return min;
}
But that probably won't do much (since the approach is basically the same as yours), a better approach would make use of an array, in which all numbers are contained, then you could easily loop through all the elements in the array, checking each time if the current element is lower than the lowest element found so far.
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
It's for an assignment so due to the fact that we haven't yet covered arrays I would assume that we can't make use of them in the answers...
That's the most probable, you could however ask your instructor.
Anyways, the code you have so far is probably the simplest you can get, taking your current C++ knowledge into account.
[EDIT]
Since finding the minimum/maximum is a common problem, you might want to do a Google/forum search on this topic.
[/EDIT]
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243