101 Posted Topics
Re: exactly...he can simply use a common header, a isPrime.c, a genPrime.c and finally a main.c which calls the two. Inside genPrime.c he can simply call isPrime(n) which is inside isPrime.c. Offcourse he needs prototypes or a common header. Edit: offcourse,you need to compile the files together. If you are using … | |
Re: you have mixed "case" in your code. If the code that you have posted is what you are trying to compile then consider the following changes: first (as vinitmittal2008 suggested) change line no. 13 to match exactly what he said, and i repeat: [CODE]typedef struct LinkedList NODE;[/CODE] observe "LinkedList" as … | |
Re: okay, firstly, repeat this a 100 times, "I'll never call main() from other functions" main() is supposed to be called by the OS, and it will get really angry if you call it instead..!! so remove all those calls to main() (line no. 31 to 33) and you'll get out … | |
Re: may be you'll just need to put a cin.getchar() right before you return from main(), or a suitable breakpoint... can't tell you more than that without looking at the code...:) | |
Re: @Jmknight...he's obviously using windows...don't know about xp... @berwick53 Are you sure you are giving your input in UPPERCASE ? otherwise your 'if' in line 112 will fail and you'll get that "this program stopped working" error (a stack overflow), which i presume is what you'r getting...right? first solve this and … | |
Re: Come out of your dizziness and think and code something solid. So far you have simply taken an input. You have not done anything about the logic so far. Also, the question itself is a bit gibberish. Please be more specific about what you want to do. | |
Re: @prisonpassioner :-O ? u better read all the posts before giving out your "solution" otherwise it leads to something called redundancy. Also, from next time, be more specific as your posts are indeed "gibberish". | |
Re: Firstly, the two of you should have explained where the OP went wrong, before giving out your (wrong, unoptimized, non-standard, non-indented) code. @shikhin: your code is WRONG A thought about optimization: the looping can be done only up to the square root of the number. You need not go up … | |
Re: well, abstract classes are "abstract" and provides "abstraction". That's one way to look at it. Think of it like this: They don't allow you to create objects, right? Now, why do you think that is required? Lets take an example, say we have a Human class which has two subclasses, … | |
Re: the first two errors are trying to say that they found string but you are trying to assign those strings into chars. Solution: Make L1 and L2 Strings. For the next two: I hope you can understand that you haven't declared the variables 'gpa' and 'total'. For the remaining errors, … | |
Re: @ pvfloripa: Do you think that after 4 years the OP is still in search of a "best" solution? Also this thread was marked solved!! You are new to daniweb, so in future keep this in mind - you should not post in very old threads (and this one was … | |
Re: Well, here's a quick answer for the difference b/w abstract classes and interfaces : Abstract classes can contain both abstract as well as non-abstract(concrete) methods. Interfaces can only contain abstract methods. NO non-abstract (concrete) methods are allowed inside an interface. In other words, interfaces are 100% abstract classes. Hope this … | |
Re: Dont hide your questons inside your unformatted code which is even without code tags. Be specific about your problem. That way we can help you better. Keep that in mind and read the community rules before posting. Good Luck. | |
Re: @ parse : Dont give out codes and that too codes that don't stick to the specs. For eg you were supposed to declare and initialize separately but you did them together. Also, when the OP was asked to study and then come up with a better solution you should … | |
Re: @tesu: The algorithm is correct. Its just that the first tw0 terms of the series must be printed separately. fibo(18) is 2584 iff fibo(0) = 0. So what you are printing as your first term should be the 2nd term (ie fibo(2) if we take the first term as fibo(0)). … | |
Re: @Andreas5 : the OP didn't want to have two functions. Though overloading could have been a possible (and perhaps more elegant) way of doing it but we possibly cannot go beyond specs...:) @c++learner : I hope you understood what jonsca suggested. As far as return statements are concerned do a … | |
Re: @shikhin : you forgot the [B]&[/B] in scanf :) it should be: [CODE]scanf("%d", &i);[/CODE] @shankarz: I hope the explanation given by shikhin is clear to you. I'll just summarize what he said: [B]Declaring[/B] a variable means to tell the compiler about the type of the variable : [CODE]int myVariable;[/CODE] [B]Initializing[/B] … | |
Re: okay, taywin already gave you an algorithm to approach the 2nd problem (about sine series). I guess you are having problems following it, so here's a bit more detailed description: Firstly look at the series carefully. There are three important things to consider. 1) You have to calculate powers...(use library … | |
Re: Think practically...do you throw away remaining cookies?? I guess you don't need to round off the no. of boxes/cases. Lets take a small example. Say the #ofCookies = 25. Then how many boxes do you need to cover all the cookies? Well, you need 3. Two boxes will contain 10 … | |
Re: hi, i have already explained your third question(the sine series) in your previous thread "three simple questions" Here's the link: [URL="http://www.daniweb.com/forums/post1265376.html#post1265376"]http://www.daniweb.com/forums/post1265376.html#post1265376[/URL] Please go to this thread and end the discussion. Don't use different threads for same problems. If you are satisfied with your previous set of questions and the help … | |
Re: firstly i congratulate you for your attempt on "being the compiler" and checking the code as the compiler would have. That's a nice approach. But unfortunately the compiler is not as logical about logical operators as it should have been. There's something called "operator precedence" which kills the fun. So … | |
Re: First things first....I am an Indian and yet with a heavy heart I believe in most of the opinions put forward so far in this thread. [B]I wish more Indians read this thread and more could THINK before going in blindly for quantity over quality.[/B] As already mentioned these for-profit … | |
Re: One more thing, BlueJ is NOT a compiler. Its just an IDE. The compiler is within the jdk file that you probably have downloaded from sun. To compile a .java file without blueJ is simple. First you need to set a classpath for the bin subdirectory inside your jdk directory. … | |
Re: wow...you know so much...:) who is the father btw?? | |
Re: Anar Diabo, do you think the OP still needs an answer? After ~FOUR years?? I think she might have got it by now or have lost all hopes and have downloaded a few custom made ones... sakshamkum: great that you are working on a similar project. We wish you all … | |
Re: Are you having all the classes in the same folder? | |
Re: well, here you go... [CODE]//first think of the max length of your array and make it a constant; const int MAX_SIZE = 256; //then declare your array char sentence[MAX_SIZE]; //now you need to ask the user to enter something printf ("please enter the string \n"); //now comes the main part...storing … | |
Re: I second WaltP...:) | |
Re: it seems that you have not bothered to STUDY about classes and objects. Otherwise this is just a very simple code regarding basics of classes and objects which after a good introduction to OOP you could have easily solved. Here's a link that may be helpful: [URL="http://www.cplusplus.com/doc/tutorial/classes/"]http://www.cplusplus.com/doc/tutorial/classes/[/URL] Also, google is … | |
Re: What the hell is this?? Are u joking with us?? Or is it that you are as stupid as it seems...!!! | |
Re: If your looking for OOP design then you can give this book a try: "Head First Design Patterns" from O'Reilly. It's very good. Regarding UML you only need to learn a few basics and the rest will come along as and if you work with it. For that you can … | |
Re: I suppose you need to enter the salary once?? Or do you have to enter it every time (that's not in the specs) If the former is the case then you need to change (decrement) your final sum inside the loop. Otherwise how will it ever become less than 1000 … | |
Re: well, it seems you are out of scope with some variables, particularly the cardTotal variable. For e.g. the cardTotal you declared in line no. 25 is not the same as the one in line no. 106. The one declared in the Check method dies out as you go out of … | |
Re: IMHO you must change line no. 9 to something like: [CODE]else if (a==b && b==c && c==a)[/CODE] The advise that finito gave you can be considered but that's not the concern in this case. Your logical checking is not right. Actually your version will only work if you input all … | |
Re: Well ifezuec, if you are wondering whats a struct...its just like a class with everything (data members as well as member functions) public by default. If you wanted strictly a class you can simply replace the "struct" with "class" but in that case your 2d matrix will no longer be … | |
Re: what you want is not clear. If your talking about interfaces as in JAVA, then as far as I know C doesn't have anything called interfaces (correct me if I am wrong). If you are talking about anything else, like an user interface or something like that then be specific. … | |
Re: i think you are slowly going towards a homework assignment....first malloc then linked list now perhaps you would ask how to add nodes or delete them...:) well, here's a link that might be some good to you.... [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/malloc/"]http://www.cplusplus.com/reference/clibrary/cstdlib/malloc/[/URL] P.S: In C++ why would you like to use "malloc" anyway. You … | |
Re: have you written any line of code so far ?? If yes, then post it. | |
Re: IMHO, I think you'll have to change your youngest_women function to something like: [CODE]void youngest_women(){ int m=0,y=age[0]; for(int i=1;i<count;i++){ if(sex[i]==1){ if(y>age[i]){ y=age[i]; m=i; } } } //end of for cout<<"The youngest women visited Bulgaria is: " <<Fname[m]<<" "<<Sname[m]<<" "<<Lname[m]<<" at age of "<<age[m]<<" from "<<country[m]<<endl; }[/CODE] First of all your … | |
Re: Thanks Dave...even i got confused for a moment. | |
Re: I think the best book for beginners to LEARN java is "Head First Java" by Kathy Sierra and Bert Bates. I simply enjoyed the book. Once you grab the concepts you can move to books like "Core Java" vol. 1 and vol. 2 by Cay Horstmann et al . These … | |
Re: as far as your code is concerned, no difference at all. Every class implements those two anyway. It depends on what you want to do with Comparable. If you want to make a list of all houses and "sort" them based on the compareTo method then you can perhaps use … | |
Re: And for that overdraft method not working.... Its the same problem as is with your constructor. You are NOT passing the correct number of arguments to it.(Madawar actually tried to tell you this only) Hope it helps. | |
Re: if you don't know already, daniweb only helps people who show at least some efforts. Just saying "help me please" wont help (and that too for homeworks!!) First try yourself. Post what you are thinking. If you have managed to write any code so far then post that too. This … | |
Re: What have you done so far?? If you are fine with nos...chars are not that different. Post the code that you have written so far. | |
Re: may i know which compiler you are using? You surely have array out of bounds in line 24. Also may i know the headers you are including?? | |
Re: @amrith92: [QUOTE]Now, for any given number, the maximum value of the factor it can have is always less than or equal to its square-root[/QUOTE] That's wrong. For e.g. sqrt(16) = 4 but factors of 16 are 2,4,[B]8[/B] (and off course 1). What you said is true for prime factors (that … | |
Re: How many times do you want DANIWEB to remind you of CODE TAGS?? They are so sick and tired that they have also watermarked "please wrap code in code tags..." in every "post reply" message box. Still you guys can't see. Its a shame. I also found that you have … | |
Re: well i copied your code and tried to compile it. Looks like, other than line 22 of your code the rest will compile fine if you take jonsca's advice and make the call to pow as [code]pow(-1.0,i+k)[/code]. It just gives you a warning regarding possible loss of precision. The second … |
The End.