I am trying to write an if statement to test whether two conditions are both true. However, my code does not work when I combine the both tests into one if statement like:

if((last_smallest < samples[i]) && (samples[i] < current_smallest))
      current_smallest = samples[i];

I know it is possible to have multiple tests in an if statement, but I simply have been unable to get it to work. When I use to nested if statements to the same effect as below, the program performs correctly.

if(last_smallest < samples[i]) 
		   if(samples[i] < current_smallest)
			current_smallest = samples[i];

Anyone know what is going on??? Both snipets compile without issue.

Edited by Jsplinter: n/a

6 Years
Discussion Span
Last Post by Jsplinter
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.