Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Real easy question but I am missing something

Posted on 2004-10-23
Medium Priority
Last Modified: 2010-04-01
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(Prime2 = true)

                              if(      load_factor >= 0.75)
Thanks I am sure it is something easy and I am missing the answer
Question by:D_basham
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12388263
I guess this line:
while(NotDivisbleYet=true && k<count)
could be:
while(NotDivisbleYet==true && k<count)

and this line:
 if(Prime2 = true)
could be:
 if(Prime2 == true)

= is the assignment operator
== is the comparison operator

Good luck,

Author Comment

ID: 12389893
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 :)


Accepted Solution

BenMorel earned 100 total points
ID: 12390926
I guess this line does not provide the behavior you want :

If "n" and "count" are integers, then the result "n/count" will be an INTEGER, and then type-casted to double.
For example , 3/4 will produce (int)0 , type-casted to (double)0 !

Here it is not what you want !

So you should do this :
load_factor = ( ((double)n) / ((double)count) );

See ya

Expert Comment

ID: 12390952
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);

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


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question