DavidB 44 Junior Poster

Are you the author of the program?
If so, why not just initialize everything at the beginning of the program so you don't have to wonder?

Are the data types all going to be numeric, as in your example?

I don't think there is an easy way to do it. Off the top of my head, one way would be to assign a Boolean variable to each variable to indicate if it has been initialized or not.

If the variables are all numeric, you might try using isnan() in <cmath>.

Also, this might interest you, and it is relevant:
Yesterday when I was looking for information about quiet_NaN, I came across several informative threads on stackoverflow. You might want to head over there and do a search for "quiet_NaN". Here are some of the more interesting/relevant threads:

http://stackoverflow.com/questions/7893531/what-is-the-best-way-to-indicate-that-a-double-value-has-not-been-initialized/7893598#7893598

http://stackoverflow.com/questions/235386/using-nan-in-c

http://stackoverflow.com/questions/6822044/c-checking-if-a-variable-is-initialized/6822126#6822126

http://stackoverflow.com/questions/235386/using-nan-in-c#236952

The post by "Motti" in the last thread has been upvoted a lot, so it might be worth investigating more thoroughly.

DavidB 44 Junior Poster

Thanks for all the feedback.

I just posted my code snippet and I used quiet_NaN() after all.
I wanted to make sure, if a = 0, the user didn't miss the fact that only one root would exist. Hopefully, I have made it blatant enough so that the user doesn't miss it. If he misses the output statement, hopefully when viewing the results and seeing a "NaN" result, he will think, "What the ...?" and go back to look at the inputs.

DavidB 44 Junior Poster

Here is my first Code Snippet contribution: a C++ sub-routine that computes the roots of a quadratic equation.

Notes:

  • This sub-routine checks if a = 0.
  • IF a = 0, then the equation is actually not a quadratic equation; it is a linear equation with one--if any--root.
  • IF the user misses the output statement alerting the user to this fact, the second root has been explicitly assigend a NaN value so that the result is not mistaken for a number.
DavidB 44 Junior Poster

Are you suggesting that I calculate the roots first and, if I discover that one doesn't exist, just reduce the size of the results vector and not even mention the fact that another root doesn't exist?

DavidB 44 Junior Poster

Hi, folks.

I would like to start posting a few C++ code snippets and thought I would start with something well-known and simple: a Quadratic Equation Solver.

I am trying to be as thorough as possible, so am also considering the possibility that a non-quadratic equation might be fed into the sub-routine.

For example, my sub-routine accepts the coefficients a, b, and c as per the standard form: ax^2 + bx + c = 0

To handle the case where a = 0 is input into the routine, I have left the components of one root unassigned. I was hoping that the output results would be something like 0xABB or some other gibberish, to highlight the fact that only one root exists, the other does NOT. However, I notice after testing the program with a = 0, the non-existent root is output as 9.25596313493178e+061. Most people would realize this is a non-answer, but I would like something that stands out more blatantly.

So I am considering using quiet_NaN. Is this acceptable practice? Or is there a better way someone can recommend?

DavidB 44 Junior Poster

Hello, Matthew.

Welcome to the DaniWeb forums. We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

It is a great place for the sharing of ideas. I am sure you will learn a lot here.

See you around the forums.

DavidB 44 Junior Poster

You are not even in the job yet, so don't take anything for granted. Many people are looking for a job and cannot find it, so IF you actually get hired, appreciate it.

Once you are there, take the opportunities to learn new things. Many people make the mistake of entering a job and focusing on their particular field of specialization--only. I think that is a mistake. Most employers will give employees exposure to other software packages (e.g. - CMS Software, ERP Software, Accounting Software, etc.) and different technologies. Make sure you learn about them when you get the opportunity. Having more to put on your resume makes the next job come sooner and easier. Gradually work your way in to the job you want.

Another bit of advice: usually it is not the job itself that makes it or breaks it for you; it is the people you work with. So don't be surprised if you find your dream job but can't stand the people you work with. Bad co-workers can turn a dream job into a hell for you. Some of the best jobs are actually not doing the specific job you want, but working with people you enjoy spending 8+ hours a day with.

diafol commented: great post +0
DavidB 44 Junior Poster

Hello, Mandi.

Welcome to the DaniWeb forums.

DavidB 44 Junior Poster

There is a pretty good paper here:

http://docs.sun.com/source/806-3568/ncg_goldberg.html

It has been around for a long time and is pretty thorough.

There is also a lot of good information about dealing with floating point numbers on Bruce Dawson's blog:

http://randomascii.wordpress.com/

Hope this helps.

DavidB 44 Junior Poster

Yikes! I think I will pass on that. I have avoided going in for something as simple as a prostrate exam.
Now I have to worry about this?! I sure hope my doctor doesn't bring this up as a way to prolong my life.

DavidB 44 Junior Poster

Interesting article. This is the first I have heard about spicy food affecting cancer.
I have read of several other foods that supposedly prevent cancer: eggplant, bitter almonds, apricot seeds, graviola, etc. Don't know if they are actually effective.
Plus, sugar should be avoided. Apparently, cancer cells use five times as much sugar as regular cells to grow. And with all the sugar in our diets, we are making a comfortable home for cancer cells. So I have tried to drastically reduce my sugar intake.

DavidB 44 Junior Poster

Do you mean you want to multiply A-matrix by B-matrix by C-matrix by D-matrix, etc.? You will have to do that one at a time.

Or do you mean you want the option of choosing among several different-sized matrices, but only two are going to be multiplied together?

Off the top of my head, I seem to recall that "Narue" posted a code block some time ago that did matrix multiplication. Just do a search of these forums.

DavidB 44 Junior Poster

It should be as easy as logging in to your account and deleting it.
For example, if I log in to my Delicious account, I can select the bookmark, and then choose to delete it.
All the other social bookmarking sites offer similar features.
I don't understand why you would think you can not delete a bookmark; after all, they are your bookmarks, which you have saved for your convenience.

gulzaifaqeeri commented: The Importance of Building a Strong Foundation for Your Career +0
DavidB 44 Junior Poster

I am not aware of any way to watermark numbers. Or maybe I am misunderstanding your question.

If you just want to save an array of numbers, and make sure they have not been altered in any way when you want to use them again, a couple ideas come to mind:

Save them in a Word document and password protect the document. Word also offers the option of adding a watermark to a document, but that isn't relevant to the security of the document.

Alternately, save the array of numbers in a PDF document and digitally sign the document. Then, in the future, if you have to use those numbers again, you will be able to tell if the document has been adjusted at all (or not). It will tell you if the document has been tampered with in any way.

DavidB 44 Junior Poster

A sitemap is a way for visitors and Google to know how pages connect to other pages within your site. For example, at the top of THIS page, you can see the following site map: "Internet Marketing > Search Engine Optimization". So now you know where you are within these forums and what level is the next level up. Some sites go deeper than that; they can have MANY more levels. And by allowing visitors to click on any of those links, they can quickly navigate to other locations within a site.

A site map is not required, but it is highly recommended. Google explicitly recommends having a sitemap on their webmaster tools pages, for example, here is one page (you could probably find many more): http://support.google.com/sites/answer/100283?hl=en

DavidB 44 Junior Poster

Hello, CW.

Welcome to the DaniWeb forums. We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

It is a great place for the sharing of ideas. I am sure you will learn a lot here.

See you around the forums.

DavidB 44 Junior Poster

By "nested loops", do you mean a loop within a loop? In this case, you don't need a nested loop anyhow.

But you will probably need one non-nested loop. "NathanOliver" gave an example of pseudo-code.
Not sure how else you could do it. Recursively?!

I suppose it depends on the format in which the data comes: in an array, ordered, spacing, in a string, etc.

DavidB 44 Junior Poster

Hello, Benedict.

Welcome to the DaniWeb forums.
Maligayang pagdating.
We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

It is a great place for the sharing of ideas. I am sure you will learn a lot here.

See you around the forums.

DavidB 44 Junior Poster

Mac Pascal, back in 1985.
Then WATFIV (FORTRAN), Turing, Turbo C, C++, HTML, Javascript, CSS, some PHP.

DavidB 44 Junior Poster

So the name of the file you are trying to open is named "F:\problem5 YES.txt"?
(I am curious if that whitespace is allowed.)

Also, I usually put a second argument in the file opener:
For example,

ifstream fin("F:\problem5 YES.txt", ios::fin);
DavidB 44 Junior Poster

I do not see a conditional statement.
On line 4, I see Total+=newValue;, but it doesn't check first to see if checkbox checked. It adds 10000 to value regardless.

You should have code like the following:

if (checkbox checked){
  Total+=newValue;
}
else {
  do nothing;  // or whatever action should occur if checkbox unchecked
}
DavidB 44 Junior Poster

How far along are you?
Are you having troubles opening the text file? Reading the file? Creating the array? Putting the data into the array? etc.?

DavidB 44 Junior Poster

PageRank has been discussed many times before in these forums. If you had just spend some time reading through these forums you would get a pretty good idea what PageRank is. In fact, you might want to look at this thread from a year ago: Click Here

And there is a lot more to be found by searching.

DavidB 44 Junior Poster

Social bookmarking sites are websites on which you can save your favorite bookmarks, and they are publicly viewable, hence, the term "social." For example, delicious is probably the biggest and best-known. There are many others. They provide another way to save your favorite bookmarks, besides memorizing them, saving them in your Favorites Toolbar, saving them in a text document, etc. Wikipedia has a pretty good write up on the topic, and a good list of sites. Start there.

DavidB 44 Junior Poster

Here is another way to create a (square) 2D array in Javascript:

var MATRIXDIM = 5;  // Dimension of a square matrix
var A = new Array(MATRIXDIM); 

for (var i = 0; i < MATRIXDIM; i++){ // Create the square Matrix
   A[i] = new Array(MATRIXDIM);
} // End for i loop

At this point, a square 5 x 5 matrix named A has been created. Now to assign data to the array, you do something like this:

A[1][2] = 25;

This assigns the number 25 to the array element in row 2, column 3 (remember, array indexing in Javascript starts at 0).

How are you getting the data in the first place? Several textboxes? A textarea box? etc.?

DavidB 44 Junior Poster

Do you Like Wine and Bear ?

Bear??!!

I have never had it. Does it taste anything like chicken? If so, then, yes, I like it. Especially with a little paprika sprinkled on it.

DavidB 44 Junior Poster

Can you go to another computer (friend's computer, public library, Internet cafe, etc.)? Perhaps you can go to another computer and download the attachment to a USB drive. If you can download from another computer, then you know the problem is not with Gmail, it is with your computer.

If the problem persists on another computer, then you know the problem is with Gmail, or your account, or perhaps just that particular attachment. In that case, you may have to find a way to deal with the problem email.

Try a few things to narrow down the problem.

DavidB 44 Junior Poster

. . . information regarding 2013 Directories List and how they are useful to us.

That is a wide open question.

1) How are they are useful? If you don't already know, why are you asking for them? Especially if you are into SEO?!

2) Are you looking for a ready-made list of directories announced in 2013? We are only 2 months into the year, so it will probably be a rather short list. I doubt a list like that has been compiled yet, but if you want to keep an eye open for the latest directories as they are announced you are better off in a forum specifically about SEO (e.g. - SP, DP, V7N, IVS, etc.).

3) I wouldn't waste time on directory submission. It used to be a method of SEO, but it is all but pointless now. Google has devalued directory submission a lot, and I hope they keep doing so. Hopefully, soon it will be completely devalued and all these useless directories can disappear and stop polluting the Internet.

DavidB 44 Junior Poster

. . . I made a suggestion . . . , go to Google and type in the search phrase, then follow it by "site:www.daniweb.com".

Perhaps a custom Google search function could be added to these forums?
I see this feature on many other forums. Even though they have the search function that comes with the forum, under the pull-down menu is also the option to perform a custom Google search, which by default confines the search to the forums.

DavidB 44 Junior Poster

Hello, Abhishek.

Welcome back to the DaniWeb forums; hopefully; you can renew a more active participation.

Congratulations on your work in the coding competition.

Through your Profile, I went to visit your blog. Looks like you got started but weren't able to keep updating it. Maybe you will find more time now to make the occassional post. I have the same problem; my blog is taking on a mathematical focus, but I am finding it hard to post regularly.

Well, all the best in your endeavors.

See you around the forums.

DavidB 44 Junior Poster

Awesome!
Thank you very much!

DavidB 44 Junior Poster

Hello, Boye.

Welcome to the DaniWeb forums.

Looking forward to your participation in these forums.

DavidB 44 Junior Poster

Ideally, it should look as follows:

Regards,

David
Numerical Mathematical Utilities

"Numerical Mathematical Utilities" is hot-linked to the URL shown in my post above (http://www.akiti.ca/Mathfxns.html) but not explicitly displayed.

And I like the space between "Regards," and "David".
(Yes, I know I am being anal. But since you asked. :) )

DavidB 44 Junior Poster

I think I just messed up my signature.

It was the same for several years: it had the anchor text I wanted and hot-linked to my website.
It was pretty much just how I wanted it.

However, I just made a small punctuation change and now my hot-linked anchor text isn't working. My signature is now four lines lumped together, not even a blank line between the "Regards," and the "David'. To me, it looks clumsy and awkward.

How do I get my old signature back? Aaargh!!!

DavidB 44 Junior Poster

Hello, David.

Welcome to the DaniWeb forums. We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

It is a great place for the sharing of ideas. I am sure you will learn a lot here.

See you around the forums.

chilly_peppers commented: i was on these forums, until the admins found out i was 12. they banned me. i was expecting the ban to disappear now but it didnt. so i made a new account. but thank you for welcoming me. +0
DavidB 44 Junior Poster

Why are you willing to consider creating a 3-dimensional array, but do not want to create an Object? I think using an Object would be the better choice. The coding work on your part would be about the same but I think using an Object would be more convenient. It is easy to use, can be passed quickly and easily into sub-routines, and changes made to the Object within sub-routines would be known outside the sub-routine. So you wouldn't have to manage several variables and pass by reference.

For example:

var personData = new Object();   
 . . .
personData.name = "Bob";
personData.lastname = "Smith";
personData.age = 34;

Using the individual data components is pretty easy with the dot operator.

And if you have to pass the Object into a sub-routine, you can treat it like a normal variable. Inside the sub-routine, it can have a different name, but you just have to remember to access the individual data components by using the same field names that you initially defined them with.

// Pass Object variable into a sub-routine
subroutine_Name (personData, variable1, variable2, etc.);

 . . .

//Within the sub-routine, the Object variable can have a different name

function subroutine_Name(inputObject1, parameter1, parameter2, etc){
 . . .

inputObject1.age = inputObject1.age + 1;

etc.
}

After exiting the sub-routine, the age component of the variable will have been changed and you can use it if you want.

DavidB 44 Junior Poster

How are you connected to the Galaxy?
Do you have a cable physically going from the micro-USB plug of the Galaxy to a USB port of a computer?

Don't forget to change the setting within the Galaxy itself. You have to tell it to connect as a media device, not just as a device whose battery needs charging.

DavidB 44 Junior Poster

I think the phrase “Blue Hat SEO” refers to totally ineffective SEO work.

A quick check of the Online Etymology Dictionary (Click Here) indicates that it may come from the old Latin term caseous (note the 'seo'), which means "soft" or "cheese-like". In turn, that Latin word, itself, has Greek origins.

When combined with the word “blue”, this phrase reinforces this perception, meaning “to make blue”, “bring down”, “depress”. Of course, the term has evolved over the years to become what it is today.

Ergo, today the phrase “Blue Hat SEO” connotes efforts—though sadly futile--made to increase a web page’s ranking in search engines. For example, if you spend a lot of time doing all the things you think are SEO techniques, but which are fruitless, that is blue hat SEO. Say you spend all day submitting a link to web directories, spamming forums, making poorly-written blog posts in barely understandable English—you think you’ve covered all the SEO bases. However, at the end of the day, you have not gotten any love from the search engines. Your flaccid efforts have resulted in no perceptible results, highlighting the impotence of your work. That, my friend, is Blue Hat SEO. In some ways, Blue Hat SEO is worse than White Hat SEO and Black Hat SEO because the former two techniques produce results; alas, the latter does not.

Compare Blue Hat SEO to a “special” date you’ve planned with a woman. You think you’ve covered all the bases: you bought …

DavidB 44 Junior Poster

Hello, Milos.

Welcome to the DaniWeb forums. We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

It is a great place for the sharing of ideas. I am sure you will learn a lot here.

See you around the forums.

DavidB 44 Junior Poster

What, exactly, are you looking for? An explanation of an algorithm for doing the inversion?

Help writing code for an algorithm you have?

Or perhaps you don't need the program (source code) itself, you just need a tool that does the inversion? In this case, most scientific calculators have that function built-in.

Otherwise, Mike has listed several pretty good resources to get you started reading about the process.

DavidB 44 Junior Poster

Hello, Lisa.

Welcome to the DaniWeb forums. We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

Alias: N1NJ4 C4T :)

What is the alias for?

In any case, welcome.

See you around Daniweb.

DavidB 44 Junior Poster

Hello, Ezekiel.

Welcome to the DaniWeb forums.
Maligayang pagdating.
We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

It is a great place for the sharing of ideas. I am sure you will learn a lot here.

See you around the forums.

DavidB 44 Junior Poster

Have you tried stepping through the program one line at a time?

You can do a couple things:
1) step through the program, and after each array element is input, view it in the debugger.
2) insert an output statement right after the input statement; then you can see if all the array elements are being input correctly.

Once you've confirmed all the array elements are being entered correctly, the rest is pretty easy.

DavidB 44 Junior Poster

Hello, Matthew.

Welcome to the DaniWeb forums. We are glad you joined us.

These forums are an excellent resource: lots of good information and many knowledgeable members here.

It is a great place for the sharing of ideas. I am sure you will learn a lot here.

See you around the forums.

DavidB 44 Junior Poster

What kind of output are you getting?
Are you at least getting the numbers input to the array correctly?

DavidB 44 Junior Poster

Right after the input line in the loop (line # 21), you should output the repeat variable, just to make sure the program thinks it is what you think it is.

DavidB 44 Junior Poster

I am puzzled that so many people actually like that smell enough to buy it. There are so many other scents to put in a can and spray on your body. Why is this one so popular right now? It really has an edge to it and makes your eyes water.

DavidB 44 Junior Poster

I come to Daniweb because it is a useful resource, although I might not post frequently.

It is a huge collection of information and many knowledgeable members so, when I need help coding or something, looking for it on Daniweb is a good place to start. If I cannot find it, then I post a question. However, I do wish the search functionality on Daniweb was much better. I am accustomed to forums that use vBulletin, and having the ability to search by user name, date, topic, etc. really helps to narrow down search results. On smaller forums, I might be able to remember who posted what when and track down a topic or code snippet. However, Daniweb outgrew being a small forum a long time ago. There is a lot of good information here; it just has to be managed better and made easier to find.

What makes me post?
A topic on which I can add something.
A topic that interests me (but is not just a spam post that stuffs the title with every possible buzzword the poster can think of).
Indication that the OP is a genuine human being, who doesn't just make short posts using Internet acronyms all over the place.

DavidB 44 Junior Poster

My pet peeve is Axe body spray. It is everywhere I go: in public transit, the malls, etc.

I think it smells terrible, and some young guys seem to bathe in it. I can't believe people are paying good money to make themselves smell like that. I prefer the smell of insect repellant. Seriously.

DavidB 44 Junior Poster

Sounds like a puzzling requirement.
After all, why would the client care what happens inside the program as long as the program works properly?

One suggestion I can make:
if you are inputting integers padded with leading 0s, make sure to specify the radix parameter, otherwise the numbers might be misinterpreted as being in Octal format (or does your client want numbers in Octal format?). For example, integer_input = parseInt(input_number,10);
Once the number is in the program, it can be manipulated however you want, used for mathematical computations, etc.

When you output the number, and you want it padded with leading 0s, then you can use a small routine like the one described at urtrivedi's link above, or write your own similar routine.

To retain the leading 0s inside the program, as the numbers are being used, would be a tricky operation; I don't know if it could even be done, or why. Are you submitting a code block to a client that will work with other code blocks supplied by other people that require the data in this format? Even so, I don't know how you could save an integer variable like, say, 000067 and still have it recognized as an integer instead of a string.