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.

Solved. I have no idea why it was not working earlier.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.