1,362 Posted Topics
Re: If your point is to ignore duplicate IDs, perhaps you need to keep a list in the function of all IDs that have been read and search that first. If it's the first time an ID has been read, then call the find function, otherwise skip the entry. | |
Re: If you're looking to create a sequence of ones and zeros, you need to do some division and modulus operations. Look [URL="http://www.purplemath.com/modules/numbbase.htm"]here [/URL]for some example of the process. You can do a 'net search and find many more examples. | |
Re: It would help if you would ask a specific question. What happens when you try to run your program? Where do you think the problem lies? Just few quick observations: line 24 ought to also include a test that count has not exceeded the array size line 27 ought to … | |
Re: That's a nice problem. When you show your work and ask specific questions, we'll be glad to help. | |
Re: Big problem, you haven't provided an implementation for `void input(ifstream& input,int studentid);` | |
Re: You need to initialize your variables in main() - set them to 0 as starting values. | |
Re: Without seeing the rest of the code, it's hard to find your problem. Is the array actually filled with valid data? What you show appears to be all integer arithmetic, so how does a floating point value come about? | |
Re: Also, the way you're using eof( ) can lead to incorrect results. When you first test it, before attempting to read from the filestream, eof( ) has no real meanning. It's not until you attemtp to read past the end of the file that eof( ) will true. If the … | |
Re: The CPU has only a tiny bit of memory, the registers. You might also consider the L1 and L2 caches to be CPU memory, but those are controlled by the cache controller logic, you don't get any direct access unless you go mucking about in kernel code. If you mean … | |
Re: Hard to help when the program works. The interface is a bit awkward in places, but it functioned for me. I entered month, number of days, then start and end time. It did some calculations and displayed the worker's info. Did this for two workers, it found both. Some indentation … | |
Re: I was going to suggest one that translates internetspeak into proper English, but I think pyTony pretty much has that topic covered. | |
Re: Shhhhhh, don't wake the necrothread. | |
Re: You need to wrap the body of your code (lines 10-33) inside a loop. When the result is displayed, ask the user if they want to find another, get at yes/no type response, check it. | |
Re: All your processing of the input value needs to be inside that first for loop. When categorizing the numbers, all you need do is test for > 0, then use an else to handle everything else that must be 0 or less. Where you add the positives and the negatives, … | |
Re: And for whatever reason, 0 is traditionally the value a program returns upon normal completion. You can return other values and for the purposes of your program define what they mean, perhaps indicating various error conditions that caused the program to not complete normally. | |
Re: Father Norton woke up Sunday morning and realizing it was an exceptionally beautiful and sunny early spring day, decided he just had to play golf. So... he told the Associate Pastor that he was feeling sick and persuaded him to say Mass for him that day. As soon as the … | |
Re: Also, if accessing data in a large 2D array, you should generally order the looping so that you work across rows, not down columns. | |
Re: In line 180 you set `head` to NULL Then in line 183 you set `temp1` to be `head` In line 186 you are making a comparison to the `temp1` which is, NULL pointer | |
Re: Are you sure you put the precision statement before any output occurs? If you mark the thread solved, it would be helpful if you tell all how you solved it. This may aid others later on. | |
Re: Close but not quite. What sort of structure are you intending to create? If it's a two dimensional array, you first allocate the pointers to the rows, then allocate the rows, like: int main(){ td p; int i; p.subj_no = new int * [7]; for( i = 0; i < … | |
Re: A great many of the errors you now see are easily corrected. Go to the indicated lines and you'll find you placed semicolons in the middle of chained outputs or made other typos. Read the error messages and do the corrections. Let us know if you have further problems. The … | |
Re: Yes, MS has a speech functionality that can accessed even in command line programs. Look at the sapi.h library. ![]() | |
Re: And, the function will never get to the close statement in any case. | |
Re: For this small program, I would make the input operation a function. You'll have to pass the x and y variables by reference is you want a single function call to get both. Or you could have an input function that just gets one value and returns it. | |
Re: Concerning the first question, or what I take the first question to be, how does the statement `while(szTarget[targetIndex])` work, or what is it doing. That's actually a pretty common technique to use when writing your own functions to manipulate c-style strings (array based, null terminated). The loop keeps examining/processing characters … | |
Re: Moschops - how do you know the GetCoefficients method isn't using reference paramters? Yes, it apparent the OP does have some confusion on this issue, as the function above has the x and y passed by reference but attempts to return both of them. `return x,y; ` will only return … | |
Re: 31.6, 44.7, both wrong. Rikkie, your code, once corrected, gives the correct response of 22.36, which is 1/2 what you show above. What did you do? One other point: For C++, the math library is <cmath>, not <math.h> | |
Re: I would first ask - Why? It's 10 years old, or more, not meant for modern systems such as Win8. There are plenty of other no-cost options available. | |
Re: Further, The array of strings (argv) is (essentially) created by the operating system at the time the program is invoked. The argc value is how many space delimited items were on the command line (including the program name) and thus how many valid strings are in the argv array. You … | |
Re: Regardless of whether the chicken or the egg came first, why did either of them cross the road? | |
Re: Colossus, from the Forbin Project. It's the progenitor of SkyNet. Or today's Democrats. I'm not sure which. | |
Re: The old Pepsi ad with the kid covered in puppies. https://www.youtube.com/watch?v=YTOWMsm6W6w | |
Re: You could still keep the seeding from reoccurring like: static bool seeded = false; if( !seeded ) { srand( unsigned ( time( NULL ) ) ); seeded = true; } | |
Re: Do your deposit functions take a value directly into a numeric variable, like: cin >> dep_amount; If so, then there's a newline left on the input stream that halts your getline without any new input to the loop variable. | |
Re: For starters, I would turn your testing into a series of if..else if statements, including the final recusive call. Then you need and else case that returns false. | |
Re: In just the bubble sort I see several typos. Don't have your sort functions call the display function - do that back in main. Please, please use some horizontal and vertical spacing and indenting | |
Re: If you're referring to the Beep function in windows.h, the quality of the sound system and speakers can make a difference between computers. Lower frequencies may not work well, and just where you lose the high frequencies will also be very system dependent. | |
Re: Want to give us a hint as to what problems you are encountering? Which functions work, which ones don't? | |
Re: Of course, on any given system (OS + compiler) on which you work, you can check the size of each data type with the sizeof( ) operator. cout << sizeof( int ); //repeat for each type you're interested in. The sizes that were given above are quite common. You'll most … | |
Re: One problem is that you wait too long to start checking for a winner. After the players make their fourth move, a win is possible. So your test should be if( i >= 3 ) //four moves have been made. Also, your last two tests are the same, checking the … | |
Re: You will have trouble when you enter anything outside the range of the target variable's type. It's usually wise to use a type that holds more range or precision that what you expect input to be, if you don't have strict control of the input. Is there a particular reason … | |
Re: Nothing shows up because there is nothing in the program above that either displays on the console or writes to file. Uncomment the call to the average function. Your reading function is missing the actual reading. In the loop, you access the array elements, but don't do an input to … | |
Re: std::string ? | |
Re: You don't actually present the problem to the student - are they supposed to telepathically know what values are returned to x and y? I would only call srand( ) once, in main( ). The way you are using it, I would expect the same to "random" values to be … | |
Re: I don't think dos.h will do anything for you related to time. Try the <ctime> library. | |
Re: First, define "efficient". I can think of solutions that are efficient in terms of speed, and in terms of memory usage. As to solving the probem, yes, an array will almost certainly be needed for any solution. It's a matter of what you put in the array, and what you … | |
![]() | Re: `while (bookTitle[] == 0)` You need to specify an index, which book title are you comparing to? The comparison should be to an empty string, represented by "" (two double quotes, no space between them.) And in the rest of the function, you also need to specify array indexes. ![]() |
Re: I don't know about freezing, but it looks like it will be waiting for you to enter another number, regardless of whether the user enters one in the valid range or not. You need a set of { } around the two statements following the `if( num >= 20 )` … |
The End.