1,171 Posted Topics

Member Avatar for jephthah

@Jephthah: (In your fixed snippet) You can replace line 38 ([ICODE]len = strlen(tempStr);[/ICODE]) by [ICODE]len--;[/ICODE] :)

Member Avatar for BNF
1
1K
Member Avatar for kookai

[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 …

Member Avatar for Nick Evan
0
2K
Member Avatar for tux4life

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

Member Avatar for Ancient Dragon
0
205
Member Avatar for spoinkgeek

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 …

Member Avatar for Amanuel Negash
-1
121
Member Avatar for rogue005

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 …

Member Avatar for alibabashaun
-1
682
Member Avatar for kennski23

[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 …

Member Avatar for peter_budo
0
328
Member Avatar for rayden150

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).

Member Avatar for extemer
0
6K
Member Avatar for justinwarner

[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 …

Member Avatar for justinwarner
0
3K
Member Avatar for kumpul101

You actually want to read a string from the keyboard, and store it in a character array? Do you want to do that?

Member Avatar for kumpul101
0
191
Member Avatar for Cheese Man 808

[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 …

Member Avatar for tux4life
0
110
Member Avatar for PDB1982

[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.

Member Avatar for tux4life
0
98
Member Avatar for churva_churva

[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 …

Member Avatar for javaAddict
0
269
Member Avatar for NewOrder

[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 …

Member Avatar for NewOrder
0
265
Member Avatar for linta

[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, …

Member Avatar for prvnkmr449
-6
215
Member Avatar for nix_xin

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: …

Member Avatar for nix_xin
0
321
Member Avatar for Jiblix

[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: …

Member Avatar for Jiblix
0
944
Member Avatar for daudiam

[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 …

Member Avatar for daudiam
0
129
Member Avatar for Clawsy

[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 …

Member Avatar for Adak
0
151
Member Avatar for kumpul101

[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 …

Member Avatar for tux4life
0
216
Member Avatar for babug

[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 …

Member Avatar for Sriman_Laxmi
0
1K
Member Avatar for anny**

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 …

Member Avatar for selfrules
0
250
Member Avatar for Ershad K

[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 …

Member Avatar for Ershad K
1
7K
Member Avatar for sourabhtripathi

[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.

Member Avatar for jaaz....
0
306
Member Avatar for Dendei

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 ...

Member Avatar for n.sehrawqat1987
0
94
Member Avatar for tux4life

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 …

Member Avatar for SHENGTON
0
476
Member Avatar for spring sun

Maybe [URL="http://www.daniweb.com/code/snippet1097.html"]this[/URL] code snippet might be helpful too :) ...

Member Avatar for technology
0
221
Member Avatar for ashish2234

[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]

Member Avatar for genie0582
0
310
Member Avatar for nsavvinv

[URL="http://stackoverflow.com/questions/397692/how-do-i-display-the-binary-representation-of-a-float-or-double"]Here[/URL] is a nice one :) ...

Member Avatar for frodothehobbit
0
6K
Member Avatar for Ayaat Monem

[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 …

Member Avatar for abhimanipal
0
278
Member Avatar for unity

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] :) ...

Member Avatar for suze_eq
0
156
Member Avatar for speedy94519

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 …

Member Avatar for WaltP
0
201
Member Avatar for AndrewYY

[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 …

Member Avatar for 0x69
0
3K
Member Avatar for chained

Could you at least post code which will compile? Also please post the defintions of [I]TYPE[/I] and [I]DynArr[/I].

Member Avatar for chained
0
129
Member Avatar for barevhayerable
Member Avatar for abhimanipal
0
385
Member Avatar for notuserfriendly

[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 …

Member Avatar for notuserfriendly
0
383
Member Avatar for rickymak

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 …

Member Avatar for tux4life
0
113
Member Avatar for jamesbondbest

[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 …

Member Avatar for WaltP
0
97
Member Avatar for rickymak

[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]

Member Avatar for Aia
0
192
Member Avatar for rickymak

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 …

Member Avatar for tux4life
0
222
Member Avatar for rickymak

[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 …

Member Avatar for rickymak
0
327
Member Avatar for camdaddy09

[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 …

Member Avatar for BestJewSinceJC
-2
151
Member Avatar for fabunmi adeniyi

Change line 36 from: [ICODE]HashSet usedNums = new HashSet();[/ICODE] to: [ICODE]HashSet[B]<Integer>[/B] usedNums = new HashSet[B]<Integer>[/B]();[/ICODE]

Member Avatar for moutanna
-1
124
Member Avatar for noobuser

[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.

Member Avatar for noobuser
0
175
Member Avatar for sourabhtripathi

[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 …

Member Avatar for 0x69
0
116
Member Avatar for johndoe444

[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 = " …

Member Avatar for sourabhtripathi
0
338
Member Avatar for bl@ck_d3ath-v2

[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 …

Member Avatar for NathanOliver
-2
1K
Member Avatar for camac

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, …

Member Avatar for tux4life
0
139
Member Avatar for invisal

[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 *= …

Member Avatar for invisal
3
211
Member Avatar for raymyster

[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 …

Member Avatar for 0x69
0
148
Member Avatar for raseru

In addition, a Win32 API tutorial: [url]http://www.winprog.org/tutorial/[/url].

Member Avatar for Frederick2
1
968

The End.