80 Posted Topics
Re: That's the problem. When day is 30, your cout statement increments it to 31, from where you try to read in the stock price for stock[31] which gives you a problem. Rather than using ++day, use day + 1, since it doesn't increment day. Also, if you're using floating point … | |
Re: [CODE]string str; getline(cin, str, '\n'); // '\n' is the delimiter [/CODE] | |
Re: Along with what L7 mentioned, in your while loop leftName and rightName isn't updated and neither are your i or length variables. Also, you'd never actually begin the loop, since you're testing 0 != 0. If you are doing an anagram, are you just trying to scramble the characters in … | |
Re: You've hit the nail on the head. You'd want structure in your programs, especially if it's a big one. In addition, separating the files keeps functions that are related confined to one area. Keep it simple. | |
Re: What moschops was referring to was creating a variable of type string, rather than one of type char[]. That way, you'd be able to read in any name and test whether or not it's equal to "Jeanne" using the compare function. Along with this, if you're initializing name to "Jeanne", … | |
Re: Using static_cast isn't really an advanced way. I mean, if you want the simplest then following the advice to simply assign it to an integer variable should suffice. You can always add a comment explaining what it does, just to make your intentions clear. | |
Re: Your default argument should be in the function's declaration. | |
Re: In your reverse function, even though you're passing r1, it isn't changed. You're only making changes to r2, which is local to your reverse function. | |
Re: guess is declared to have a size of 50, but ranges from 0 - 49, right? You're trying to read into guess[50] which should be outside of the range. Another thing, why declare a size of 50 if you're only apparently using one string to hold the guess? Keep in … | |
Re: Even if you set MAX_ACCOUNTS to be 5, your do while loop still checks that counter is less than the integer 10 rather than MAX_ACCOUNTS, assuming that 1 is continually entered after counter surpasses MAX_ACCOUNTS. You'd be pretty much trying to use an object that you never created, is what … | |
Re: I'm not sure if this is what you're leading towards, but you can always allocate memory during execution with malloc and a given size. | |
Re: Check how many times you're updating sum4 per each iteration. | |
Re: As caut mentioned, you can't read in with a comma. In addition, you could always make the class variables private and use a member function to set them rather than allowing main() direct access to them. | |
Re: You're counting how many times the function is called recursively, correct? If that's the case, then you'd need a counter. Still, it wouldn't just be any counter though. You'd need one that retains its value even after it's used again. This looks like C++, so think of a what is … | |
Re: Also, for future reference, the = sign signifies assignment. Later on, if you're comparing, for instance, numeric values then a double equals sign == is used to check for equality. But, as the poster above me mentioned, used strcmp to compare strings. | |
Re: I believe j should be assigned the value of i, seeing that after the completion of the inner loop, one value would be sorted, hence not needing to start the search from subscript 0 again. | |
Re: Do you want to know what source code is, or do you want someone do to your assignment? | |
Re: Your program is using the array subscript to serve as a node which is the problem. Even though you removed the data, the second subscript, pq[1], isn't going to change. Have you tried doing it with a linked list? | |
Re: In C, arrays start with 0. In your case, you'll always be adding some data out of the preallocated boundary you've set when declaring your array. Also, your code is confusing the way it's structured there. Use the code tags to situate your work better. Here's hoping it helps. | |
Re: It should actually be "<= k" rather than less than. Use 9 as an example and you'll see. The for loop ends and fails to mod 9 against 3, hence returning a value of 1. | |
Re: Your code is in the wrong section though. Maybe asking if it can be moved to the Java section would garner better help. | |
Re: Well, you can start off with the first two: 2, and 3, and store them in an array. From there, think of the conditions for a number to be prime and implement it, keeping in mind to compare each successive value against the prime array. Here's hoping it helps. | |
Re: You can try seeding the random number generator with a call to time(). | |
Re: Rather than asking others to do the assignment, a little bit of research would go a long way. [URL="http://scriptasylum.com/tutorials/infix_postfix/algorithms/infix-postfix/index.htm"]Read and understand.[/URL] | |
Re: Also, your code is overly complicated. Since you know the stopping value "maxElements", why not loop around that number of times while calling the pow function? | |
Re: Why are there unused local variables in the function power? Also, bear in mind that your function is designed to take two arguments, yet you only supplied one in the function call. | |
Re: Make a conscious effort and post something you're having difficulties with. | |
Re: You can create an array of structs that can hold those three pieces of data. Afterwards, sorting based on the hours can be done, starting with those from hour 0 - 23. |
The End.