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.

Find the highest and lowest number in array with PIC16F877A

Status
Not open for further replies.
min is initialized to 0 in the beginning. So, 0 is the minimum value. Don't initialize min or initialize it to max value you can get. Initialize it to 10000 if your adc values doesn't exceed 10000.
 

else if (array < min)

remove "else" from the line mentioned above from the code.

- - - Updated - - -

min is initailized to zero outside the for loop.

It doesn't affect the value printing.
 

Yes. snishanth. You are right. I didn't see that else. else if has to be replaced by else. If else if is used it only checks the max values and never checks for min values.
 

Yes. snishanth. You are right. I didn't see that else. else if has to be replaced by else. If else if is used it only checks the max values and never checks for min values.

else if has to replaced by if and not else, there is also a chance of else if working well... the only problem is min = 0 initialization.. it can be min = 10000 or some big value..
 

sorry, I mean "else if" should be repalced with "if".
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top