- 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
1,608 Posted Topics
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. … | |
Re: I hope you find it. The policy here is to post a question you have about code you are working with and someone will try to help out. Please post questons about the code you come up with. | |
Re: Sounds like good practice. When you have a specific questions please post them. | |
Re: Well, the result really isn't: 2 3 44 5 666 7 888 99 is it. Write out a table. the table should look something like i n i%n output 2 2 0 2 is prime 3 2 1 3 3 0 3 is prime 4 2 0 4 is prime … | |
Re: //limit entry of password2 to 2 tries tries equal zero while tries less than 2 start body of while loop enter password2 if password2 equals password start body of if statement tries equals three end body of if statement else start body of else statement display error statement end vody … | |
Re: [code]NodePointer temp; while(origPtr != NULL)//cycle through origList temp = new Node(origPtr->data); //copy data in current node of origList lastPtr->next = temp; //add temp to end of this list lastPtr = lastPtr->next; //advance lastPtr to end of this list origPtr = origPtr->next; //go to next node in origList[/code] What if the … | |
Re: Just think of namespaces as another level of organization. If the only programs that were ever written were only one screen long, then things like namespaces probably wouldn't be necessary. However, many/most of the commercial programs out there are very long and developed by different teams of developers. This means … | |
Re: The simplest answer to your question would be to use a loop to generate more than one random number at a time if you don't want to do it explicitly as already described. I suspect the more real problem is that want to avoid giving the same number to two … | |
Re: Try putting the include on line 6 of your original post, in the list of the other includes, and use the example syntax where ever desired to have the output be to 2 decimal point precision. the version posted will only work with the header file ionmanip (witout the .h). … | |
Re: >>direction on how to sort In line 103 you compare index j and j + i but lines 106 and 107 you are swapping indexes j and j - 1. Why are you using different indexes? Either use j + 1 in all three lines with 0 <= j < … | |
Re: Loops allow you to the same thing over and over again. Arrays contain information of a similar type. Using a strategy that combines those two topics should allow you to do what you want. | |
Re: use cstdio instead of stdio.h and iostream instead of iostream.h | |
Re: Accept input as a single string of size n. Start at index i and look at index i + 39, call it j. if input[j] is whitespace, then output all chars from i to j. If j isn't whitespace then go backward from j until you find a whitespace char … | |
Re: The most important thing is to learn how to indent your code to make it easier to read. Some of the most respected responders on the site won't look at your code if yout dont' do it. Then, it doesn't look like you have initialized the variable called position on … | |
Re: Line 26 is a function declaration. What you really want is a function call. It could look something like this: float temp = sum(sales, numMonth); cout << temp << endl; | |
Re: Your question seems a bit ambiguous. Lists are typically implented either as an array where each item follows the other in sequential memory or as a linked list where each item is stored in a node and each node contains pointer to the address in memory of the next node … | |
Re: C++ string objects can be compared with the equals operator, the return value is true or false, so it can be used as the conditional of an if statement. string input; string a; string b; if(input == b) else if (input == a) else | |
Re: use a loop that checks user vs computer input for equality before doing test for winner/loser.[code] int userInput; int computerSelection; //get user input //start with computerSelection equal to userInput computerSelection = userInput; //now change selection until they are different while(computerSelection == userInput) //get new computerSelection //then compare userInput and computerSelection … | |
Re: Links like previous and next are used for doubly linked lists, which are easy to search forward and backward from a given node in the list. Links like rightChild and leftChild are used to create binary trees, which can improve search times compared with linked lists. Both lists and trees … | |
Re: Hey, slow down tenderfoot. You seem to be moving so fast you're stumbling over your own feet. Inclusion guards are great. I'm glad you know about them. However, they should go at the top of the file so you don't include std or fstream or other files multiple times if … | |
Re: I doubt it. Looks like everything is initialized fine to me. But look at the difference between the operators used in lines 29 and 31. One of them is correct, the other is wrong. Fix the mistake and I think you will get the response you want. Your program will … |
The End.