Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I want a program using if condition to find big number

Status
Not open for further replies.
suppose you have three nos
a=9 b=10 c=11 then

Code:
if(a>b)
{
  if(a>c)
  {
    A is bigger
  }
  else
  {
    C is bigger
  }
}
else if(b>a)
{
 if(b>c)
 {
  b is bigger
 }
 else
 {
  C is bigger
 }
}
 

bignumber = 0;
if(a > bignumber) bignumber = a;
if(b >= bignumber) bignumber = b;
if(c >= bignumber) bignumber = c;

leaves the biggest of a,b and c in bignumber. It also caters for any of the numbers being equal and it uses one less compare instruction.
If you want to expand it to more numbers, put them in an array and loop through them using the same method.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top