- Strength to Increase Rep
- +15
- Strength to Decrease Rep
- -3
- Upvotes Received
- 211
- Posts with Upvotes
- 196
- Upvoting Members
- 121
- Downvotes Received
- 6
- Posts with Downvotes
- 6
- Downvoting Members
- 6
Re: Now would that be hot fudge brownie ala mode or Gobi? | |
Re: the sizeof() operator returns the number of bytes of memory an object occupies, not the number of digits in a number. So use one loop to fill the array with digits counting as you go, and then another loop to do the multiplication, or use a running subtotal to keep … | |
Re: comment out both of these lines: cout<<queue[0]<<queue[1]<<queue[2]<<queue[3]; in sort() change this:[code] int size=10; nt j,temp,i; for( i= 0; i < size - 1; i++) { for(j = i+1; j < size; j++)[/code] to this:[code] int j, temp, i; for(i = 0; i < lastElement; i++) { for(j = i+1; j … | |
Re: To clarify terminology, I think of the scope resolution operator in C++ as the double colon, ::. I don't see that in Clinton's code, but I may have missed it. That being said: 1) Don't resurrect dead code. If you want to base your code off of this post, then … | |
Re: Control statements need: 1) an identifier (if, else, switch, for, while, etc) indicating this is a control statement 2) a condition (or conditions) that must be met for the following body of code to run 3) a body of code to run To write the body of code you generally … | |
Re: I don't do much programming in Java. But here's how I think about it, though it's bound to be off somewhere. In Java each function is a class. It has a name, declaration, and a body. It is declared using public static void name of function(parameterList) followed by a function … | |
Re: Why bother with strings or char as a type for choice at all. Why not just have the user enter an integer value not used in the menu to exit, say 6 or -1 or 999 or maybe 1234? | |
Re: Intinalize sum to zero in convertToDecimal() before you try to add something to it. You never use the values passed to convertToDecimal() in the form of roman. Instead, you ask for additional input in the form of romanNum. | |
Re: You don't need to put the name of the file to open in quotes unless you hard code it at time of compilation. | |
| Re: Now convert it to do this: Use a single-subscripted array to solve the following problem. The array should be used instead of all the individual counters. Each array element will represent one of the ranges. Be sure to initialize all the elements of the array to zero before you use … |
Re: Sequentially read in a char, a string, and a double. The char goes in one array, the string in another and the double in a third. The index of the array and the array name is the key to accessing any one of items in any array. So when the … | |
Re: Also: ask yourself--- 1) how does getline() know when to stop extracting information from the input stream? 2) What can you do to avoid default behavior, if you want to? All of that information should be in your documentation as well. 3) what is the difference between a line and … | |
Re: It looks like you are trying to do everything at once without taking the time to learn the details. For example, you can declare variables global before declaring main(), but not after. To make the variables local to main() then use an opening curly brace after declaring main and stareting … | |
Re: It means "don't return anything". Similar to empty parameter brackets when declaring/calling functions. It can make code easier to read, particularly if you get into the habit of using only one return statement per function. | |
Re: Use the if/else statement after completing the while loop. | |
Re: Since you have a list3 listed I assume you want to create a third list representing the merged lists, leaving the initial lists intact. So: 1) let curr1 work down list1 2) let curr2 work down list2 3) let curr3 work down list3 4)initialize curr1 and curr2 to be the … | |
Re: If you move the ouptut statement outside of the for loops, then you should always print out the lowest value in the matrix. If you want to out put the three lowest even values in the matrix then there are a variety of options. One approach would be to sort … | |
Re: There are multiply implementations for what we call strings. One version is C style strings, also called nulled terminated char arrays. You can't compare or display all elements of an array at once using the == or the << operators, with one expcept. Because of the terminating null char, you … | |
Re: Well, there are many types of strings. In standard C and C++ they are null terminated char arrays, meaning the null char needs to be the last char of the characters stored in the array. These strings can be manipulated by a number of standard functions. std:strings objects are instances … | |
Re: Looks like you had trouble posting the code. Please try again. Learning to debug is as a crucial aspect to successful coding. If you don't know how, then now is as good a time as any to learn. The options are to learn how to use a debugger, or to … | |
Re: 1) No reason to use the key word static, that I can see anyway. 2) Some compiler implementations might default elements in arrays of type int to a value of zero, but I wouldn't rely on it if you are writing code in C++. 3) int arr[150] will contain 150 … | |
Re: To pass information, and maybe change values in passed parameters where changes are retained outside the current function. | |
Re: The nested loop idea is fine, but many of the details are wrong. First the while loop is not doing anything, so why have it. Second, you are missing a closing brace for one of the loops. Third, can you see boolean values known as true or false? I can't. … | |
Re: Use a loop to control each row to be printed by using a counter that is increased by 1 each time through the loop. Then within the body of the loop use an output statement to display the word ROW and the row number (which is actually directly related to … | |
Re: To "optimize" it a little further without getting too technical you could keep track of each prime along the way. Then to check if current number is prime just check to see if previous primes up to the square root of the current number are a factor rather than checking … | |
Re: Put the nested loop to print out the board in a separate function. When using the smaller board be sure you don't go out of bounds by using indexes relevant for the final board. The only values the board will hold are *, space char, equal sign and an i. … | |
Re: strcpy(c.str,a.str); When you call the above on line 26, c.str doesn't have any memory allocated to it yet. Determine the length of p and q, and then allocate adequate memory to str to hold p, q and a null char. Then call strcpy() as you did and then you can … | |
Re: zekester: Here's some additional thoughts. If you find them useful, fine, if not, so be it. Just so you know (I'm sure Duoas already does) there is no need to change the struct declarations into class declarations. In C++ the only distinction between classes and structs is that data members … | |
Re: I'd like to say it's a reference to Alan Lerner, who was a playwright and author of the play Camelot, about a utopian mythical kingdom, based on the book "The Once and Future King". But, in reality, it's a phonetic spelling of learner, since there's always something I want to … | |
Re: It may be that your compiler doesn't recognize the point of entry indicated by void main(). Try int main() instead. In the past some compilers allowed main() to be declared with return type void, but it was a proprietary extension and not all compilers let you do it that way. … |