Hey guys :),
Thanks for any help ahead of time.
I'm writing a program that would take the input scores of seven judges and throw out the highest and the lowest.

#include<iostream>
using namespace std;


int main() 
{
float a=0, b=0, c=0, d=0, e=0, f=0, g=0, score=0, difficulty=0;

cout << "First Judge Score \n";
cin >> a;
cout << "Second Judge Score \n";
cin >> b;
cout << "Third Judge Score \n";
cin >> c;
cout << "Fourth Judge Score \n";
cin >> d;
cout << "Fifth Judge Score \n";
cin >> e;
cout << "Sixth Judge Score \n";
cin >> f;
cout << "Seventh Judge Score \n";
cin >> g;
	if(a < b && c && d && e && f && g)
	{	
		a=0;
	}
	else if(b < c && d && e && f && g)
	{	
		b=0;
	}
	else if(c < d && e && f && g)
	{	
		c=0;
	}
	else if(d < e && f && g)
	{	
		d=0;
	}
	else if(e <f && g)
	{	
		e=0;
	}
	else if(f < g)
	{	
		f=0;
	}
	else
	{
		g=0;
	}
	if(a > b && c && d && e && f && g)
	{	
		a=0;
	}
	else if(b > c && d && e && f && g)
	{	
		b=0;
	}
	else if(c > d && e && f && g)
	{	
		c=0;
	}
	else if(d > e && f && g)
	{	
		d=0;
	}
	else if(e >f && g)
	{	
		e=0;
	}
	else if(f > g)
	{	
		f=0;
	}
	else
	{	
		g=0;
	}
score= a+b+c+d+e+f+g;
cout << "Total score " << score<< "\n";

Basically, the problem I am having is that when it is making the comparisons is that it isn't checking all the values that are inputted. So, if a = 1.3 and b = 2.6 ..... then a will be set to 0 even if c=1.1 (lower than both a and b). I was wondering if anyone could help me figure out how to make sure the && works to check all the values. I already tried doing it individually i.e. if((a<b) && (a<c) .... etc.)

>>if(a < b && c && d && e && f && g)
Do you know what that statement does? It first checks if a < b, then if that is true it checks if c != 0, if that is also true it checks if d != 0, etc. If you want to check of a < c, and a < d ... then code it like this

if( (a < b) && (a < c) && (a < d) && (a < e) && ...)

It would probably be a little easier if you put the values in an array to that you could use loops.

ahhhhh see when I first tried what you suggested I ended up only changing the first if statement then debugging to see if that worked, but I probably just tested wrong. I took your advice and ended up just switching to an array though.

Thanks for the help :)

This question has already been answered. Start a new discussion instead.