1,171 Posted Topics
Re: @Jephthah: (In your fixed snippet) You can replace line 38 ([ICODE]len = strlen(tempStr);[/ICODE]) by [ICODE]len--;[/ICODE] :) | |
Re: [QUOTE=asad jaan;823481]Here is the shortest code for finding the fibo series [/QUOTE] [B]I also found a short code (nearly exactly the same as yours):[/B] [CODE=cplusplus] #include <iostream> using namespace std; int main(void) { int f0 = 0, f1 = 1, fn, repeat_times; cout << "Enter number of elements (the first … | |
Hi, please don't blame me for reinventing the wheel, I was bored and had nothing to do, so I thought: what would I write? And apparently this code is the result :P | |
Re: Hey firstPerson, where the h*ll do you see in his spec that he has to use a class? [QUOTE] This system should be implemented [U][B]using structure and array[/B][/U]. i am required to develop a structure which contains student details such as Student ID, Student Name, Nationality and Gender. [/QUOTE] To … | |
Re: I already know this kind of game: we make suggestions and never it's a good suggestion because either it's too difficult, or too easy, or too boring, or whatever else. You know what you can and can't, you also know what interests you, combine your creativity with these two elements … | |
Re: [B]>>share me a lick please.. so [COLOR="Green"][I][U]i[/U][/I][/COLOR] can do it.[/B] Good thing that you wrote this post, because I'm going to refer to it anytime you do a request that involves doing it for you. So now, if you could provide us with some evidence that shows your effort, you've … | |
Re: Are you sure that you typed it in as [ICODE]import java.util.[B][COLOR="Green"][U]S[/U][/COLOR][/B]canner;[/ICODE]? ('[U]S[/U]canner' starts with a capital letter). | |
Re: [B]>>Which yes, it works, but I was wondering (First chapter of the book), is there any way that you think they meant to do it?[/B] Since it is the first chapter of the book, I think they mean to do it as follows: [CODE] public class JavaPattern { public static … | |
Re: You actually want to read a string from the keyboard, and store it in a character array? Do you want to do that? | |
Re: [QUOTE=Cheese Man 808;1331139] [CODE] do { System.out.println("Enter number of years for the loan an in integer: "); numberOfYears = input.nextDouble(); System.out.println("Enter the loan amount : "); loanAmount = input.nextDouble(); } while (loanAmount <= 0 || numberOfYears <= 0) ; [/CODE] [/QUOTE] I do not find it logical to get two … | |
Re: [B]>>That printed the correct total? That's impossible unless you called the price method.[/B] True. [B]>>Or am I missing something here?[/B] Unless I'm missing it too I can confirm that you're not missing anything. | |
Re: [QUOTE=churva_churva;1329543]The suggestion you said to me makes my program more complicated....why don't you just help me how to solve it by editing my code...[/QUOTE] I don't follow your reasoning. If he edits your code, by applying his suggestion(s) to it, then your code will be the same in complexity as … | |
Re: [QUOTE=NormR1;1329821]The basic way to prevent NPE is to make sure all the object references you use are NOT null. Either assign them all some non-null value or if there is a possibility that a reference could be null, [I]test if it is null: if(objRef != null) before using it.[/I][/QUOTE] Personally … | |
Re: [QUOTE=linta;1010975]plz help me 2 finish my c++ proj on supermarket.i need the exact details of the funcns,sub calculatns............. [/QUOTE] [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]Don't use l33t speak here[/URL]. [QUOTE=linta;1010975] urgent[/QUOTE] Let's see what my dictionary says about the word 'urgent':[QUOTE=tux4life's dictionary] back away from anyone who uses this word on a forum. [/QUOTE] Anyway, … | |
Re: Here's an approach that works for integers of any length. (By [I]length[/I] of an integer I mean: the amount of digits that integer consists of). Pseudocode for the algorithm [CODE] While integer > 0: Extract last digit from integer** Add extracted digit to Sum Divide integer by 10 [/CODE] **Hint: … | |
Re: [LIST] [*]Add [ICODE]import java.util.Scanner;[/ICODE] to the top of your program (outside your class). [*]Remove lines 10 and 11. [*]On line 23, change [B]int[/B] to [B]double[/B]. [*]Line 25 needs some modification, change it from: [/LIST] [ICODE]System.out.println("A person with weight "+weight+" lbs and height "+height+" inches has bmi = "[COLOR="Red"]+bmi[/COLOR][COLOR="Red"]+"[/COLOR]); [COLOR="Red"])[/COLOR][/ICODE] to: … | |
Re: [QUOTE=daudiam;1328652]But then, this should not work too [CODE]Short a=34;[/CODE] But it does. There are as many cast/box conversions here.[/QUOTE] From the Java Language Specification (3rd Edition): [QUOTE] [U][B]5.2 Assignment Conversion[/B][/U] ... A narrowing primitive conversion followed by a boxing conversion may be used if the type of the variable is … | |
Re: [QUOTE=Ancient Dragon;1327948]@Adak: I'm pretty sure you probably know this, but for those who don't: The reason it failed is that Turbo C is a 16-bit compiler and the programs is produces is limited to [B]640 [I]Meg[/I] RAM[/B], mimus the amount needed for the operating system and other drivers. It actually … | |
Re: [QUOTE=Katana24;1326744]You could also use "StringTokenizer" to split the string up and get the initials of each of the tokens[/QUOTE] The String method split() is generally recommended for new code. From the Java API Docs: [QUOTE=Java API Docs] StringTokenizer is a legacy class that is retained for compatibility reasons although its … | |
Re: [QUOTE] So with that being said my statements are theories and I strongly support/believe them... [/QUOTE] Then there's a potential danger that you conclude wrong things from a wrong 'theory'. If you plan to use your 'theory' in Mathematics, you should first be able to prove it mathematically, and since … | |
Re: I you want to draw a graph on the screen, you could simply make use of a graphics library (for instance [URL="http://www.talula.demon.co.uk/allegro/"]Allegro[/URL], actually a game library but it supports simple operations like drawing lines (what you need if you want to draw a graph)) ... On the other hand, you … | |
Re: [QUOTE=manish.ranjan;1218064]the program and logic both are very correct...!![/QUOTE] You didn't carefully read the first post, the OP asked whether there's a solution available which conforms to the ANSI/ISO C++ standard, since your code uses unportable functions (from conio.h), it doesn't conform to the standard, and thereby is not a good … | |
Re: [QUOTE]A simple rule of thumb is finish up all the expression to the left, then come and evaluate the expression to the right of the pointer[/QUOTE] I just follow the [URL="http://www.google.com/search?&q=c+operator+precedence"]operator precedence[/URL] rules. | |
Re: I think what you mean is RAD (= Rapid Application Development) Consider using [URL="http://www.microsoft.com/express/vc/"]Microsoft Visual C++[/URL] or [URL="http://www.turboexplorer.com/"]Borland Turbo Explorer[/URL] ... There are free editions for both of them ... | |
Well, I have a very strange problem with my laptop: sometimes it wants to boot and sometimes it doesn't want to boot. First of all, I want to specify what I mean with doesn't want to boot: If I press the power button of my laptop, then the LEDs of … | |
Re: Maybe [URL="http://www.daniweb.com/code/snippet1097.html"]this[/URL] code snippet might be helpful too :) ... | |
Re: [B]Edit:: Don't bother reading this.[/B] Writing [ICODE]i=i++;[/ICODE] is essentially the same as writing: [CODE=c] i=i; i++; [/CODE] and because it's the same variable here it's essentially the same as writing: [ICODE]i++;[/ICODE] | |
Re: [URL="http://stackoverflow.com/questions/397692/how-do-i-display-the-binary-representation-of-a-float-or-double"]Here[/URL] is a nice one :) ... | |
Re: [QUOTE]Why computer only supports 0 and 1? because it is easy to understand for the computer.[/QUOTE] I just wanted to add this for the sake of clarity: [QUOTE] Computer systems are constructed of digital electronics. That means that their [B]electronic circuits can exist in only one of two states: on … | |
Re: C++ Beginners Guide (from Herb Schildt), you can get a free ebook copy at Microsoft's site: [URL="http://msdn.microsoft.com/en-us/beginner/cc305129.aspx"]http://msdn.microsoft.com/en-us/beginner/cc305129.aspx[/URL] :) ... | |
Re: I think the error is lurking here: [CODE] inp = fopen("first_file", "r"); outp = fopen("second_file", "w"); [/CODE] Your intent was probably: [CODE] inp = fopen(first_file, "r"); outp = fopen(second_file, "w"); [/CODE] You should also add checks to see if the file was opened successfully. And if you're serious about C … | |
Re: [QUOTE]For the sake of readability[/QUOTE] I don't see how this will make your code more readable. It will only introduce complexity, and I think it won't be useful anyway, because the [I]initialize(x)[/I] macro will only work if no statement has been executed in the function it is "called" from. The … | |
Re: Could you at least post code which will compile? Also please post the defintions of [I]TYPE[/I] and [I]DynArr[/I]. | |
Re: [QUOTE]it is easy[/QUOTE] I know. Could you show us your attempt? | |
Re: [QUOTE]now the next task is to create a SINGLE dimensional array with enough size to fit the 2d array and load the 2d array there in row major order.[/QUOTE] Well, the first thing you need to figure out is: how many elements should the single dimensional array contain? That's a … | |
Re: In addition to what Aia said about [ICODE]c = '\t'[/ICODE]: The assignment operator produces a value, values can be used to control an if-statement, like in your example. That's the reason why your code will still compile and run. In C every zero and non-zero value are respectively equivalent for … | |
Re: [QUOTE] tell me where i am wrong [/QUOTE] The flaws are in your encryption routines, here's a fix: [CODE] int kk=strlen(cm); for(i=0,j=0;i<kk;i++) /* changed <= to < */ { cm[i]=cm[i]^key[j++]; if(j==strlen(key)) { j=0; } } [/CODE] Do the same for your second encryption routine and your program will work the … | |
Re: [QUOTE]I am trying to understand why c has to be an integer and not a character for EOF.[/QUOTE] [url]http://www.drpaulcarter.com/cs/common-c-errors.php#4.1[/url] | |
Re: Please wrap your code in tags the next time. Question: [QUOTE=rickymak;1220212]I do not know how to get the program to execute the program's printf() function, bottom portion of the program, to print or show the calculations for the number of blanks, tabs and newlines. There are no compiler or linker … | |
Re: [QUOTE]what does "if (c=='\n')" mean in this context?[/QUOTE] It checks if the variable c contains the value of the newline character '\n'. [QUOTE]so if 10 is entered, this is when nl increments up one?[/QUOTE] No, if a newline character occurs in the stream you're reading from, then [I]nl[/I] increments up … | |
Re: [QUOTE]I didn't post this for experienced programmers, I understand it's simple, that's the idea. It's for beginners on the forum, so really it's kind like a tutorial. So you can stop blasting insults at me, and yes I know how to do this, if you will notice the due date … | |
Re: Change line 36 from: [ICODE]HashSet usedNums = new HashSet();[/ICODE] to: [ICODE]HashSet[B]<Integer>[/B] usedNums = new HashSet[B]<Integer>[/B]();[/ICODE] | |
Re: [B]@noobuser:[/B] scanf() leaves the newline character in the input buffer, that's why your code doesn't work the way you intended, [URL="http://www.drpaulcarter.com/cs/common-c-errors.php#4.3"]this page[/URL] describes how to fix that. | |
Re: [B]@0x69:[/B] What I understood was that you state that the following isn't a definition: [ICODE]int *p;[/ICODE]. [url]http://web.archive.org/web/20050207005628/http://dev.unicals.com/papers/c89-draft.html#1.6[/url]:[QUOTE=C89 Standard]"Object --- a region of data storage in the execution environment, the contents of which can represent values. Except for bit-fields, objects are composed of contiguous sequences of one or more bytes, the … | |
Re: [B]@AD[/B]: [QUOTE=Ancient Dragon;1207577]That doesn't work [QUOTE]1 2 HelloWorld 3 len = 1 Press any key to continue . . .[/QUOTE] [code] int main() { char R[255] = {0}; int s, e, n; scanf(" %n%s%n %d", &s, R, &e, &n); int len = e - s; cout << "len = " … | |
Re: [QUOTE=bl@ck_d3ath-v2;865897] plz make USER class as m getting alot of difficulties in it...i will user ur code as a reference code and will write my own code after undertanding it [/QUOTE] No, you write it, Daniweb isn't a homework completion service :P Your question was a bit vague, don't ask … | |
Re: I also have a C/C++ background, I'm an intermediate programmer, and I'm currently using those books for learning Java: [LIST] [*][URL="http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208/ref=sr_1_1?ie=UTF8&s=books&qid=1272646023&sr=1-1"]Head First Java 2nd Edition[/URL] ( Covers Java 5.0 ) [*][URL="http://www.amazon.com/Big-Java-Cay-S-Horstmann/dp/0470105542/ref=sr_1_1?ie=UTF8&s=books&qid=1272645989&sr=8-1"]Big Java 3rd Edition[/URL] ( Covers Java 5.0 / 6.0 ) ( Covers Java from a practical point of view, … | |
Re: [QUOTE=invisal;1196688][B][COLOR="Red"]1st Piece[/COLOR][/B]: [B]Reduce the Calculation[/B] [INDENT] For example: [icode]k = (168 * m) / 2;[/icode] This can be reduced to: [icode]k = 84 * m;[/icode] [/INDENT][/QUOTE] Uh? You meant: [ICODE]k = 84 * m / 2;[/ICODE] [QUOTE=invisal;1196692][B][COLOR="red"]2nd Piece [/COLOR][/B]: [B]Everything Is Not the Same [/B] [INDENT] For example: [icode]k *= … | |
Re: [B]@raymyster:[/B] These are posts written by you: [QUOTE=raymyster;1192050]i post questions here so i can get some scientific feedback from peers who are in the same technology. unfortunately i made this mistake yet again & i asked here expecting some normal people. it seems this forum is just filled with fcktard … | |
Re: In addition, a Win32 API tutorial: [url]http://www.winprog.org/tutorial/[/url]. |
The End.