D_basham
asked on
Real easy question but I am missing something
How do I let my program check that load_factor <= .75 when I have load factor as a double type but still returns zero instead of a decimal value? Here is the code I am running
while(NotDivisbleYet=true && k<count)
{
if(count%k==0)
{
NotDivisbleYet=false;
count++;
}
else
{
k++;
}
if(k>=count)
{
Prime2=true;
if(Prime2 = true)
{
load_factor=(n/count);
}
if( load_factor >= 0.75)
{
Prime2=false;
NotDivisbleYet=true;
count++;
k=2;
}
}
}
Thanks I am sure it is something easy and I am missing the answer
while(NotDivisbleYet=true && k<count)
{
if(count%k==0)
{
NotDivisbleYet=false;
count++;
}
else
{
k++;
}
if(k>=count)
{
Prime2=true;
if(Prime2 = true)
{
load_factor=(n/count);
}
if( load_factor >= 0.75)
{
Prime2=false;
NotDivisbleYet=true;
count++;
k=2;
}
}
}
Thanks I am sure it is something easy and I am missing the answer
ASKER
jaime. I appreciate the help but I did figure it out. And you were right. Anywasy I make a deal with you help with this question I will acept your answer. How do I take a string that I am reading from a file and find its ascII value? Thanks :)
cs
cs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For your 2nd question:
A C-String is a array of ascii values! :)
For example :
char sBuffer[1024];
FILE* fp;
fp = fopen("example.txt", "rt");
fgets(sBuffer, 1024, fp);
fclose(fp);
Now if the string read is "Hello world !", then sBuffer[0] will contain ascii code for 'H', sBuffer[1] will contain ascii code for 'e', etc.!
sBuffer[i] is a 'char' type, so it's a 1-byte integer.
You can try this with this sample code :
printf("%u", sBuffer[0]); // will print "72" in our example
Ben
A C-String is a array of ascii values! :)
For example :
char sBuffer[1024];
FILE* fp;
fp = fopen("example.txt", "rt");
fgets(sBuffer, 1024, fp);
fclose(fp);
Now if the string read is "Hello world !", then sBuffer[0] will contain ascii code for 'H', sBuffer[1] will contain ascii code for 'e', etc.!
sBuffer[i] is a 'char' type, so it's a 1-byte integer.
You can try this with this sample code :
printf("%u", sBuffer[0]); // will print "72" in our example
Ben
while(NotDivisbleYet=true && k<count)
could be:
while(NotDivisbleYet==true
and this line:
if(Prime2 = true)
could be:
if(Prime2 == true)
= is the assignment operator
== is the comparison operator
Good luck,
Jaime.