2,045 Posted Topics

Member Avatar for corby

Would it help you to know [code] char a = '1'; a++; [/code] will give you '2'? Now use the array indicies to offset the value by the number of rows (with the appropriate number of columns) and by the leftover columns. Trial and error should get it if nothing …

Member Avatar for mrnutty
0
111
Member Avatar for iamcreasy

EOF is not a string it's normally a negative integer. Use your getline function to drive a while loop. I would suggest the following though someone probably has a better solution which doesn't require the user to press enter twice (as it's just not clicking with me today). [code] while(getline(cin,str,'\n')) …

Member Avatar for WaltP
0
131
Member Avatar for KRal

What is the problem you are experiencing with the code. That's what Zcool is trying to get you to express. "It doesn't work" is not enough for anyone to go on. What do you expect from it and how is it breaking? If you don't know that go back and …

Member Avatar for dusktreader
0
121
Member Avatar for dabeechman

(x - checksum) must be less than 100 AND (x - checksum) must be greater than -100 (or you can use absolute value but this is much cheaper)

Member Avatar for jonsca
0
72
Member Avatar for zukkoor

Your code is kind of all over the place. The first thing you should be aware of is the syntax for declaring and defining a function (here is a rough layout): [code] #include<iostream> using std::cout; //can also put "using namespace std;" (no quotes) //but that can clutter up your namespace …

Member Avatar for jonsca
0
73
Member Avatar for nukes88

I believe if you specify a constructor other than a default one you must define a default one. So just pop it into the header file of your class (as you only need the [icode] MyConstructor {} [/icode] variety). Then you won't even need it in your implementation file.

Member Avatar for jonsca
0
170
Member Avatar for neethumol

Try it out on paper for something simple like 10/2 (repeat your subtraction of until you get to zero). A pattern will emerge. Determine a "base case" when you should stop subtracting.

Member Avatar for jonsca
-2
40
Member Avatar for Specialafrican

I'm confused. "tags" is an int (line 16), and you're reading into like it's a string (line 41) and you're trying to compare it to multiple characters (line 56) within a spot for a single character (single quotes). I'd say grab a good book and spend at least a week …

Member Avatar for jonsca
0
95
Member Avatar for pinsickle
Member Avatar for jonsca
0
163
Member Avatar for sleepybug

Is there a reason for returning 0 from your methods regardless of the outcome. Also in your definitions you need to put the return type [COLOR="Red"]int[/COLOR] [icode]Complex::Set_C(double x,double y) [/icode] though I suspect you made them ints to make the compiler happy anyway which isn't the right approach. If you're …

Member Avatar for jonsca
0
203
Member Avatar for MrJNV

Big question what is the access specifier of all of these? [code] bool DieselTypeStatus; //ok Truck(); //ok void Truck(bool); //wrong - no return type ~Truck(); void DieselTypeStatus(bool); //wrong-duplicate name bool getDieselTypeStatus()const; [missing - declaration for setDieselTypeStatus(bool)] [/code]

Member Avatar for dusktreader
0
108
Member Avatar for srinath3

You don't need to pass in another string to your show() method as you already have access to the one within the object. It should just be [icode]cout <<p; [/icode] or you can [icode] #include <cstdio> and use puts() [/icode] P.S. When you are asking for help in the forums …

Member Avatar for jonsca
0
118
Member Avatar for iammfa

You only did the calculation once: [code] double angle=0; double sinAngle = sin(angle); [/code] This doesn't magically assign that function to sinAngle, it evaluates it at angle 0 and prints it over and over again in your loop. Leave the declaration [icode] double sinAngle; [/icode] outside and move the [icode]sinAngle …

Member Avatar for jonsca
0
119
Member Avatar for Narue

im not going to write you the code so you can submit it your teacher Spend about 5 additional minutes on the site and you'll realize this is absolutely absurd. I respect your freedom to express your opinion (whether I agree with it or not is another story), could you …

Member Avatar for dusktreader
7
2K
Member Avatar for HiImBen

What doesn't work about it? Also please enclose your code in code tags: [noparse] [code] //code goes here [/code] [/noparse] There's still a few minutes left on your editing time for it.

Member Avatar for kplcjl
0
134
Member Avatar for gnarlyskim

Do you actually need the numbers for calculation within your method? If not just take them in as char and check versus '1' (etc.) in lines 10-17. If you really need the numbers themselves, take them in as char and convert to the numerical value by subtracting '0' e.g., [code] …

Member Avatar for gnarlyskim
0
442
Member Avatar for eaon21

You have a series of if/else if statements where those variables are assigned with no else statement at the end. What happens if the system goes through those choices and your value doesn't fit any of the criteria -- the variable goes unassigned. So either make your last else if …

Member Avatar for Geekitygeek
0
232
Member Avatar for riotburn

Firstly f_int takes a double for a parameter and x is a character. Beyond that, though, when you read the value into the function f_int doesn't suddenly become that function. Each time you use that function name in I_simpson that method will be called again and you will be reprompted. …

Member Avatar for jonsca
0
1K
Member Avatar for c1979h

So start by asking yourself what would 1 iteration look like, then 2, then 3. Find the commonalities and use your loop to automate the whole thing. In doing these types of computations generally 2 variables are used, one that holds the prior value, one that holds the next value …

Member Avatar for jonsca
0
124
Member Avatar for newcuser

Change your while loop to a do/while loop with the same loop condition. Move your prompt for the salesperson number into the loop. That way it's called the first time through and any subsequent times. Line 20 has the incorrect format specifier for a double, it should be %lf instead …

Member Avatar for jonsca
0
203
Member Avatar for cassds

Anytime you have an if statement without braces following it, only the next line down is included as part of the if statement. [code] if (condition) x = y; //what gets evaluated pending true condition cout <<"whatever "; //new program statement, if statement done else //compiler says where did this …

Member Avatar for cassds
0
829
Member Avatar for Stefano Mtangoo

Check out AD's [URL="http://www.daniweb.com/code/snippet249201.html"]code snippet[/URL] it's about file sizes but the code to traverse the directories should be along the lines of what you want. All else fails, google it again.

Member Avatar for Stefano Mtangoo
0
120
Member Avatar for mebob

FWIW, nobody's mentioned it yet -- but check out [url]http://gmplib.org/[/url]

Member Avatar for vmanes
0
440
Member Avatar for hirafaryal

Use ./ that will go element by element (I'm assuming that's what you are looking for). If you're looking for matrix inversion times another matrix than for inv(A)*B you need A\B.

Member Avatar for jonsca
0
35
Member Avatar for gertails

Welcome. What have you written so far? If you haven't started writing what do you have for information on the dates of the divisions?

Member Avatar for Nick Evan
-2
106
Member Avatar for jballen87

Create your own class with + - * / overloaded. This is an [URL="http://www.c-sharpcorner.com/UploadFile/prasadh/OperatorOverloading11142005003229AM/OperatorOverloading.aspx"]example for matrices[/URL] but it's similar (complex will be less complicated). Give it a go and post back when you get stuck (or if you have code already post it and someone can look it over).

Member Avatar for ddanbe
0
857
Member Avatar for ccie007

It's going to be tricky because we don't have access to your libraries. I'm sure they are wrappers for the standard functions but that's not a given.

Member Avatar for jonsca
0
211
Member Avatar for modyutd

Welcome. What do you have so far? I'm assuming you've done some work with OOP concepts beforehand so which do you think would be most appropriate?

Member Avatar for jonsca
-1
154
Member Avatar for PDB1982

Just start j off at i+1. That way you're comparing 0 with all the rest, 1 with from 2 onwards, etc., etc. If you need to keep track of whether or not you find a birthday more than twice keep the values in an array and check your new entry …

Member Avatar for jonsca
0
198
Member Avatar for froggy1976

[quote]The Soda class should include the pure virtual function while the Juice class should include the other virtual function. [/quote] My stuff is a bit rusty so bear with me if I'm missing something obvious but aside from varying the access specifiers (pub,priv,prot) of the two methods and using a …

Member Avatar for jonsca
0
88
Member Avatar for wolfkrug

I didn't compile and run your program yet, but try putting the srand() call out in main() so it's only done once.

Member Avatar for tetron
0
164
Member Avatar for lewashby

The problem is that I believe that a majority of folks on this board run the VC# IDE. Without loading it up and running it we can't tell what's the normal setup for Mono. A suggestion I've given to other users with that IDE is to tag your posts with …

Member Avatar for jonsca
0
542
Member Avatar for Stefano Mtangoo

Everything you always wanted to know but were afraid to ask: [url]http://oreilly.com/catalog/make3/book/index.csp[/url]

Member Avatar for jonsca
0
98
Member Avatar for stryker4526

Are you allowed to pass anything into ReadQuestion? somehow you have to send the streamreader object in so it can maintain the position in the file each time. Also, there's no way to access the private question variable in the TriviaQuestion class.

Member Avatar for jonsca
0
111
Member Avatar for sleepybug

main should always return an int, not be void. You need to make x and y reference variables, otherwise you're passing them in and they are changed but this is not reflected in the original variables. [icode]void A(Complex a,double & x,double & y) [/icode]

Member Avatar for jonsca
0
106
Member Avatar for Narue

Wow. I'm speechless and totally honored. I'll have to return the favor: [B]Nick Evan:[/B] Well what can I say a great moderator and a great guy( when he's not [URL="http://www.daniweb.com/forums/thread255764.html"]running over elderly men on their bikes off the road for the sake of a good story[/URL]). When I first got …

Member Avatar for jonsca
2
512
Member Avatar for wilsonz91

Place it inside of main() [code] int main() { srand( time(0) ); [/code] A seed is a starting point in the internal sequence for a pseudo-random number generator. Giving the same seed twice would result in the same sequence of numbers. For more info, check out the tutorial on [URL="http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_rand.aspx"]Narue's …

Member Avatar for wilsonz91
1
201
Member Avatar for burkeyb

The for loop on line 55 is actually correct (I think the other poster misread it, it took me a couple of times too). It's legal it just seems a little unorthodox, IMO and definitely hard to read. You don't define the function that it calls yet either. You'd written …

Member Avatar for jonsca
0
314
Member Avatar for MatthewSedam
Member Avatar for jawaad17
Member Avatar for ddanbe
0
58
Member Avatar for bbabarajj

Add 1.0/1.0+1.0/2.0+... when you do integer division (e.g., 1/2) regardless of the variable the result is going into it still still gets truncated. If you haven't already make sure your result is declared as type double otherwise nothing will work.

Member Avatar for bbabarajj
0
2K
Member Avatar for Metraton

Can you post more of your class and perhaps a few lines of your text file? It's not readily apparent (at least not to me anyway) what the problem is from the bit you posted.

Member Avatar for jonsca
-1
79
Member Avatar for froggy1976

Your method fireQuestion is inherited (publicly) from the base class so you don't need to redeclare it on line 96, it's already a part of your methods in the derived class. In order to call it you need [icode] aColstudent->fireQuestion(mystring,20,0.5,10,20); [/icode] anytime after line 129 (I have no clue what …

Member Avatar for jonsca
0
150
Member Avatar for soapyillusion

I'm assuming x1 thru x5 are your data points? The definition of the standard deviation involves first finding the mean of the values. Then find the variance by summing (the difference between data point i and the mean)^2 divided by either the number of values (for an entire population) or …

Member Avatar for dusktreader
0
165
Member Avatar for Anarionist

[code] if(name==s[0-4]) <-------?? { string name="******"; } [/code] Creative syntax? How about a for loop: [code] for (int i = 0;i<4;i++) { if(name == s[i]) name = "**********"; } [/code] if you pass in name by reference you will get the change otherwise how is your new name going to …

Member Avatar for dusktreader
0
141
Member Avatar for mikabark
Member Avatar for mikabark
0
326
Member Avatar for Stefano Mtangoo

Check out [URL="http://stackoverflow.com/questions/236129/c-how-to-split-a-string"]this thread[/URL]. It's not exactly what you want but it gives some good ideas of how to roll your own.

Member Avatar for jBat
0
95
Member Avatar for hsp700

The key to this situation is that even when you are not using getchar within a loop the extra '\n' is still in the input stream. Since you are not accessing the stream again it just becomes a distant "memory" as your program finishes. Compare that to when you are …

Member Avatar for hsp700
0
132
Member Avatar for PDB1982

[icode] #include <ctime>[/icode] Then anytime before you use rand put this statement into your program once: [icode] srand((unsigned)time(0));[/icode] This gives rand a seed based on the current time.

Member Avatar for mrnutty
0
459
Member Avatar for Orusaka

If blocks is an int array, can't you just change line 8 to: [icode]readLevel >>blocks[rows][cols];[/icode] As long as your files are laid out in a logical manner e.g., [code] 0 1 2 3 4 5 6 7 [/code] it should work

Member Avatar for WaltP
0
94

The End.