hi,
i have this program!

I enter numbers until 999(exit)
if i enter <0 and >100 it shows " number must be between 0 and 100.."
thats fine!!
but if i enter 999 for exit the program than i dont want that message
How can i fix it??

Second problem is calculate the factorial, it isnt working, Where is my mistake? Example i enter 4 it shows fac 6 but it should be 24

thanks

Code:
/*
sum of first and last numbers
average of first three numbers
product of last two numbers
largest of all numbers
greatest common divisor (gcd) of last two numbers
(gcd of two integers is the largest integer that evenly divides each of the numbers)
factorial of last number
(the factorial of a nonnegative integer number (n) is the product n*(n-1)*(n-2)..1;
for example factorial(4)=4*3*2*1=24)
grade for all numbers (H:85-100, D:75-84, C:65-74, P:50-64, F:0-49)
*/


#include<iostream>

using namespace std;
int main()
{



	// variable declaration
	long fac =0;
	int count =0,data=0;
	int first =0,second_last=0,last=0,total=0,largest=0;
	int second=0,third=0,val=0;
	int i;

	// read value from key board
	do
	{

		cout<<"\nPlease Enter a Number( 999 to exit): ";
		cin>>val;
/*
Here is the problem. I tried if(val<0 || val>100 & val!=999)
but is not working, the program shows everytime the cout: The Number must be..."
if i enter 999 i would like the program doesnt show the sentence because is the exit number
How can i fix it??
*/
		if(val<0 || val>100 )
		{

			cout<<"\nThe Number must be between 0 and 100, Try again!";
			continue;
		}

		else
		{
			cout<<"The Grade from your number " << val <<" is: ";

			if(val>=85)
			cout<<"H";
			else if(val>=75 && val<=84)
			cout<<"D";
			else if(val>=65 && val<=74)
			cout<<"C";
			else if(val>=50 && val<=64)
			cout<<"P";
			else
			cout<<"F";


			cout<<"\n";
		}

		// set count
		count++;

	// first value
	if(count==1)
	{
		first=val;
		total+=val;
		largest =val;

	} 
	// all other values

	else if(val!=999){

	// second last
	second_last = last;
	//last
	last =val;

	// sum of all values
	total+=val;

	// find largest values
	if(largest<val)
	largest = val;

	// get second value
	if(count==2)
	second = val;
	else if(count==3)  //third value
	third = val;
	}


	}while(val!=999);

	// find factorial
	fac =1;
	for(int i=1;i<last;i++)
	fac*=i;


	int gcd = last;

	// find gcd of last two numbers
	if(gcd>second_last)
	gcd = second_last;

	for(i=gcd;gcd>1;i--)
	{
	gcd=i;
	if( (last%gcd)==0 && (second_last%gcd)==0)
	break;
	}



	cout<<"\n";

	// display data
	/*
	the sum of first and last numbers,
	average of first three numbers,
	product of last two numbers,
	largest of all numbers,
	the greatest common divisor of last two numbers,
	the factorial of last number and
	the grade for all numbers preceding 999
	*/
	cout<<"\nThe sum of first and last numbers : "<<(first+last);
	cout<<"\nThe average of first three numbers : "<<((first+second+third)/3);
	cout<<"\nThe product of last two numbers : "<<(last*second_last);
	cout<<"\nThe largest of all numbers : "<<largest;
	cout<<"\nThe GCD of last two numbers : "<<gcd;
	cout<<"\nThe factorial of last number : "<<fac;
	//cout<<"\n\nThe grade for all numbers : ";

	cout<<"\n";

	// pause
	getchar();
	getchar();

	// return
	return 0;
}
[/QUOTE]