I need to try and get this code to come out to 42.4 any suggestions?
Here is my code it's coming out to 42 so I am off somewhere but can't figure it out.
//Declare all required variables
double dblAverage; //the average should allow for decimal values
int intPrimeCount = 0; //this represents the total count of prime numbers
int intPrimeTotal = 0; //this represents the sum of all prime numbers
bool blnPrime;
int intDivisor; //use this variable in the Mod operation
short intNumberToBeTested;
for(intNumberToBeTested = 2; intNumberToBeTested <=100; intNumberToBeTested++)
{
blnPrime = true ;
for (intDivisor = 4; intDivisor < intNumberToBeTested; intDivisor++) if (intNumberToBeTested % intDivisor == 0)blnPrime = false;
if (blnPrime == true)
{
}
}
dblAverage = intPrimeTotal / intPrimeCount;
Console.WriteLine(dblAverage);
}
}
2006-12-02
13:16:58
·
4 answers
·
asked by
Christina
2
in
Computers & Internet
➔ Programming & Design