Re: Newbie Problem
- From: Kelly Brookes <kellyb@xxxxxxx>
- Date: Sun, 28 Jan 2007 15:02:35 +0530
Larry Tooley wrote:
I am new to C and am using "C How to Program" to get started with my C
education. I am working an exercise where I am supposed to use only
arithmetic, equity and relational operators, and the "if" statement to
determine the largest and smallest of three integers. It seems like there
is an easy answer, but I just haven't come up with a solution. It has
been a long time since CS101 with Pascal so pardon my ignorance.
Thanks for the help.
Larry
/*Maximum of three integers*/
int max(int a,int b,int c)
{
return ((a>b&&a>c)? a:(a>b &&a<c)? c:(b>c)?b:c);
}
/*Minimum of three integers*/
int min(int a,int b,int c)
{
return ((a<b && a<c)?a:(a>b&&a<c)?b:(b<c)?b:c);
}
.
- References:
- Newbie Problem
- From: Larry Tooley
- Newbie Problem
- Prev by Date: New Way to Search the Information - Ogleo.com - An Integrated Search
- Next by Date: Re: Newbie Problem
- Previous by thread: Re: Newbie Problem
- Next by thread: Re: Newbie Problem
- Index(es):
Relevant Pages
|