1,362 Posted Topics

Member Avatar for nemoo

Looking at AD's version above, line 25 has a common typographic error (hey, we all do this from time to time!) Line 19 could be improved by setting the loop limit as [inlinecode]for( i = 3; i < n/2 +1; i += 2 )[/inlinecode]. This will save doing tests for …

Member Avatar for vmanes
0
106
Member Avatar for ekahbelista

Would you care to fully describe your problem? Please see the link at the top of this forum page: [url]http://www.daniweb.com/forums/thread78223.html[/url]

Member Avatar for vmanes
0
122
Member Avatar for still_learning

Your logic continues testing all letters, and when the loop ends all you know is the state of the final comparison (first and last letters.) When a mismatch is encountered, you should immediately exit the loop. Or, initially set the RESULT to true, assuming a palindrome. If a mismatch is …

Member Avatar for Lerner
0
94
Member Avatar for superrg86

Did you not see the answers when you asked this same question yesterday?

Member Avatar for vmanes
0
87
Member Avatar for joshmo

Are your variables: day_count,month_count,year_count doubles or ints? The function is expecting references to doubles, but by their names I'd expect the actual arguments to be declared as integers. As Narue said, a full example of the problem would be helpful. Val

Member Avatar for joshmo
0
82
Member Avatar for superrg86

In your array declaration [inlinecode]stackArray = new string[value]; [/inlinecode], you are trying to use a string (value) where you need a constant integer. That is, there should be a number inside the square brackets. It's not clear here, but if stackVal is also an int, again, you cannot assign a …

Member Avatar for WaltP
0
88
Member Avatar for maysda19

Look at your variables in the if statement [inlinecode] if (transCustNum == custNum) [/inlinecode] Are they the same as what you are reading into from the files? Then, you are reading in one customer record and possibly many transactions records. This can put you out of transaction data before running …

Member Avatar for vmanes
0
95
Member Avatar for toneeg

AD - no disrespect, but I don't want you programming for my bank! 8-) float is not a good choice for dealing with money amounts - the problems of (lack of) precision show up very easily. Even using doubles can lose pennies quickly the more you manipulate the numbers. That …

Member Avatar for toneeg
1
347
Member Avatar for beepa

Welcome. You'll find there's a C++ forum in the Software Development section, which is a better place for this question. You were on the right track with the ignore( ) function, but you used it improperly. Your goal with that is to remove any trailing spaces and the newline after …

Member Avatar for beepa
0
144
Member Avatar for ChaseVoid

It appears that GCC is compiling your program thinking it's a C program. If you can set DJGPP to call the compiler as "g++" instead of "gcc", it will compile and run correctly. I'm not very conversant in DJGPP's configuration settings, nor and I clear why GCC is not correctly …

Member Avatar for Duoas
0
304
Member Avatar for tarekkkkk

Not reading the error messages from your compiler? A little more explanation of where you feel you are having a problem will help us to help you. Val

Member Avatar for tarekkkkk
0
111
Member Avatar for raul28

[QUOTE=EnderX;465587]1 + 4, maybe?[/QUOTE] Math like this? [url]http://www.youtube.com/watch?v=Bfq5kju627c[/url]

Member Avatar for scru
0
130
Member Avatar for Gadgetman_53

Well, consider your line: [code] else if((AMPM == "AM" || AMPM == "am") && (hours >= 10 || hours <= 11)) [/code] the Boolean operator should be AND not OR, same as you did in the 0 to 9am block. or you could simple test for equality to 10 OR …

Member Avatar for Gadgetman_53
0
876
Member Avatar for danbellinger1

You've answered your question. It is a limitation of the precision of the long double - 15 digits in this case. I'm betting you're using M$ Visual C++ - it limits long double to 8 bytes, same as a plain ole double. If you ran the same code in other …

Member Avatar for vmanes
0
189
Member Avatar for jaepi
Member Avatar for paradox814

That is a default value for z. Thus, you can call the function with just two arguments, and z will be assigned the value 1. If a third argument is passed to the function, z will be assigned that value. Val

Member Avatar for Duoas
0
333
Member Avatar for dasani

Problem 1 - your are taking the input before prompting the user. Restructure your loop as: [code] cout << "Enter a string at least 8 chrs long: "; while (cin>>word) { len = word.length(); count++; word1 = word.substr(0,3); //rest of processing here cout << "Enter a string at least 8 …

Member Avatar for dasani
0
129
Member Avatar for T Mike

Dells have a reputation for being finicky about memory. You might try the Dell user forums for specific advice on your model. [url]http://www.dellcommunity.com/supportforums/board?board.id=insp_general[/url] Val

Member Avatar for T Mike
0
218
Member Avatar for sirkraven

Really, all you do to change a struct to a class is change the keyword. The only significant difference between a class and a struct is the default access level - class defaults to private, struct to public. Otherwise, they are the (99.999%) the same.

Member Avatar for twomers
0
102
Member Avatar for meiyantao
Member Avatar for gerronk

I find that C++ textbooks in general completely ignore the topic of command line arguments, so I won't tell you to look in the book. Here are a few links that may help you to understand how to do this: [url]http://www.cprogramming.com/tutorial/lesson14.html[/url] [url]http://malun1.mala.bc.ca:8080/~wesselsd/csci161/notes/args.html[/url] The short version is that argv[] is an …

Member Avatar for Lerner
0
159
Member Avatar for bleonard989

Your problem lies in the intermediate variables you use in the whichfib( ) function: [code] long double whichfib (int num) { int count=2, newnum1, newnum2, newnum; long double fnum; [/code] Your use of long double is good for dealing with the large values that will result. You should also use …

Member Avatar for bleonard989
0
114
Member Avatar for zandiago

Structs do nothing to replace functions or arrays. Rather, structs make it easier to use functions and arrays when you have multiple pieces of information, possibly of different data types, that relate to a single object. Using your example, if you did not have structs, you would need three separate …

Member Avatar for zandiago
0
158
Member Avatar for garc2541

Besides making the code more readable, I think you need to clarify what you mean (or what the assignment means) by the "average of the sum of the squares/cubes". What your code appears to be doing, is for each number 5 through 49, you are adding the squares of each …

Member Avatar for vmanes
0
102
Member Avatar for coolbreeze

A major problem is how you are reading in data and controlling the loop. You read in a first and last name, then first off in your loop read first and last name again. So your input is out of sync with the actual data. When using eof( ) to …

Member Avatar for chizy2
0
140
Member Avatar for maheen

For problems 1 and 3, look at what you can do with integer division and modulus operations ( / and % ). #3 is actually the easier problem, if all you have to do is display the result. For the problem 2, are the input dates also given as year, …

Member Avatar for vmanes
0
124
Member Avatar for dabu

Yes. Generally speaking, any place you can have a single statement, you can use multiple statements enclosed in curly braces { }

Member Avatar for vmanes
0
82
Member Avatar for tom1989

Oh, there's the problem. It should be: H C++ is a case sensitive language. (sorry, couldn't resist. too much time spent on usenet. Really, tom, please post the full code file and problem description.)

Member Avatar for vmanes
0
92
Member Avatar for sohanonline

You've pretty much answered your first question - the >> and << operators are shifting the bits of the initial value of x. In binary, the byte that stores decimal 5 is 0000 0101. Shift that left two place, you get 0001 0100, which is 20. This new value is …

Member Avatar for sohanonline
0
72
Member Avatar for pearly

Parthiban's suggestion to pass the address of each character of number2 [code] value=atoi(&number2[x]); [/code] is not quite going to do what it appears you think the atoi() function is doing for you. atoi( ) give the integer value of the "string" pointed to by the char*. So, if number2 holds …

Member Avatar for pearly
0
1K
Member Avatar for Duki

Your array based solution is limiting in that you have set the array size to the number of values to display. What about a purely iterative solution, that does not need the excess memory, and is not logically limited in the number of values to display? [code] #include <iostream> using …

Member Avatar for Duki
0
758
Member Avatar for garc2541

A better design is to have the prime( ) function only return the 0 or 1 indicating primeness. Let main( ) be responsible for the actual printing of the number and * if appropriate. Your for loop is only printing the values that are prime. A little modification will fix …

Member Avatar for WaltP
0
110
Member Avatar for jun835035

Yes, in general mixing sizes is ok, as long as pairs of modules are same sized. Having different sizes in the two banks may have an impact on dual channel usage, I can't speak to that particular aspect. Val

Member Avatar for vmanes
0
60
Member Avatar for jobi.tv

MS Visual C++ 2005 Express free download at: [url]http://msdn2.microsoft.com/en-us/express/aa700735.aspx[/url]

Member Avatar for WaltP
0
93
Member Avatar for sugarflaps

As written, your variable num_tri is controlling the size of the triangle, not the number of them. To do what you intend to do, the outer loop of draw_tri() should control the number of triangles (based on num_tri), then you need a set of nested loops in there that does …

Member Avatar for vmanes
0
79
Member Avatar for koolboy
Re: help

It may help to draw a picture of the data layout. [code] (index) 0 1 2 3 4 5 6 EmpID array | 12345 | 93948 | 87654 | 34564 | 43210 | 000111 | 007 | hours | | | 12.0 | | | | | rate | | …

Member Avatar for prushik
0
112
Member Avatar for jamesny89

Also, your main loop control is a bit off. [code=c++] do { //show the menu cin >> userChoice; if ((userChoice>5||userChoice<1)) cout << "Not a valid choice try again: " << endl ; cin >> userChoice ; system("pause"); // I'm not gonna comment on how annoying this is! system("cls"); //Switch for …

Member Avatar for zandiago
0
87
Member Avatar for veronicak5678

Let's start with the easy thing - why does this function return anything, and more importantly, your two return statements at the end will not do what you may think you're doing. Only the first return statement will execute, because once it does, you leave the function and the second …

Member Avatar for veronicak5678
0
110
Member Avatar for gee1288
Member Avatar for pyramid

Nichito is right about lines 57 & 58 - they have no place in this program, they do nothing useful other than cause it to end before displaying your results. His revision to the calc function body does not change anything, just compresses three lines into one. Saves a couple …

Member Avatar for pyramid
0
86
Member Avatar for DemonSpeeding

You can use >> operator to get the row/column values as ints, then read the data as individual chars [code] inFile >> rows >> columns; infile.ignore( 10, '\n'); //ignores up to 10 characters, or until newline //or infile.ws( ); //eats up the whitespace [/code] Then begin to read your data …

Member Avatar for DemonSpeeding
0
202
Member Avatar for koolboy
Re: help

What does the error message tell you? The answer you need is probably right there in the message. At least, look at the line the error message points you to, and carefully examine what your code is doing, versus what you think it's doing.

Member Avatar for parthiban
0
101
Member Avatar for Underdog67

Or, to avoid having to reset year to EOF each time, [code] do{ cout << "Enter a year: "; cin >> year; if( cin.eof( ) ) break; // rest of program here [/code] And similarly, the loop test can be written as [code] }while ( !cin.eof( ) ); [/code]

Member Avatar for Underdog67
0
821
Member Avatar for Koldsoul

As to the final bit always stating 7 days exercised, it's because you've made one of those typo errors we all tend to make from time to time. [code] if (counter = limit) cout << "The number of days excercised is " << counter << endl; [/code] You are assigning …

Member Avatar for Koldsoul
0
270
Member Avatar for toko

Your getChoice( ) function gets user input, but does not pass it back to main( ). [code] cout << "\nPlease enter number for your choice: "; cin >> x; return x; //add this so the choice gets sent back to main( ) } [/code] Val

Member Avatar for toko
0
300
Member Avatar for onlyled12

From the problem description, it seems you should be pretty well into the course by now - loops and functions are requirements. That last paragraph give you quite a bit of information on how you ought to structure the program. The two functions are really quite simple, doing some comparisons …

Member Avatar for zandiago
0
430
Member Avatar for krizz

Assuming you understand how to write a recursive function, you need to establish what the base case is for this problem - when a parameter for the current term passed in is equal to the upper limit (10 in this case, but best also passed as a parameter for flexibility …

Member Avatar for anirudhbsg
0
992
Member Avatar for The Dude

What does terrestrial radio (versus satellite or internet delivered content) have to do with the matter? The copyright holders who license their material to the broadcasters (any type) expect the same personal use/commercial use protections and royalties. Val

Member Avatar for lasher511
0
86
Member Avatar for The Dude

In real rodeo, he'd be a champ. He rode it for way more than 8 seconds! Val

Member Avatar for jbennet
0
41
Member Avatar for geekychick

I don't think there's any "random numbers" being stored. Keep in mind that the array num[] does not get cleared out every time you read in a new string. It simply get overwritten from the 0 position for as many characters (including the terminating NULL) as needed. So, if on …

Member Avatar for hollystyles
0
119

The End.