Posts
 
Reputation
Joined
Last Seen
Ranked #557
Strength to Increase Rep
+6
Strength to Decrease Rep
-1
89% Quality Score
Upvotes Received
39
Posts with Upvotes
29
Upvoting Members
19
Downvotes Received
3
Posts with Downvotes
3
Downvoting Members
3
7 Commented Posts
5 Endorsements
Ranked #341
Ranked #607
~51.2K People Reached
About Me

a technology enthusiast and a passionate coder

Favorite Tags
c++ x 78
c x 49
java x 45
Member Avatar for shubhamgore

@nbaztec and others I think the main loop that checks for primes can be iterated from: [CODE]for (int i = 2; i <= n/2; i++) //where n is the number to be checked for[/CODE] I think it'll be a bit faster. And also, using break may also reduce unnecessary iterations.

Member Avatar for markanderson4
-6
870
Member Avatar for myadav
Member Avatar for NP-complete
0
338
Member Avatar for opel123

It is possible. What do you think should be the strategy? It looks like a homework question, so we'll only provide hints. But first think of something yourself and we'll help you build on it. Also, please specify what your input files look like so that we have an idea …

Member Avatar for opel123
0
237
Member Avatar for nivedita.valluru

Please be more specific... is it a user defined function or a standard function like, say, strncpy()? Most of the standard functions of C are available in C++ but a few C++ specific functions won't be available to C and you cannot use them in C. Please give more details.

Member Avatar for deceptikon
0
102
Member Avatar for tiggermesho
Member Avatar for jalpesh_007
1
231
Member Avatar for meowmonkey

@meowmonkey: can you post your solution (if that's not a problem!) so that we can have a look if what you did was indeed the best that could have been done... Well, you asked for the best way and having 3 levels of iteration (for->while->for) doesn't sound quite optimal...

Member Avatar for NP-complete
0
238
Member Avatar for general2012

@general2012: why did you start 2 threads for this? I have replied in similar lines as AncientDragon in the other [thread](http://www.daniweb.com/software-development/c/threads/443264/copy-string-into-a-structure). Check that out for the printf problem as well... Along with not using gets, you should also not cast the output of malloc() and you should make a habit …

Member Avatar for general2012
0
186
Member Avatar for rotenegg

Example: int fib (int n) { if (n <= 1) return n; else return fib(n - 1) + fib(n - 2); } But the iterative approach is much better in terms of complexity! That is, for large n's the iterative version will be much faster than the recursive one. Well, …

Member Avatar for NP-complete
0
200
Member Avatar for general2012

Why its not working: 1. p->count is never initialized to anything. But the main problem is this: 2. You are trying to copy a C-string to a character. p->name[*any index*] refers to a single character and not a C-string. So strcpy fails. 3. Again, you want to print a C-String …

Member Avatar for general2012
0
5K
Member Avatar for SMYussef

> Could you guys help me solving this? :) Offcourse! But first, you need to show us some proof of efforts (that's DaniWeb rules, btw) Try to read up on arrays in the Java (Oracle) [tutorials](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html), and come up with something yourself. We'll help you build on that...

Member Avatar for stultuske
0
132
Member Avatar for silvercats

> then why is there even a namespace? That's there so that YOU can use your own namespaces. In large programs, you may face name conflicts (especially if you're just a part of a 100 developer team!). To avoid that you may have custom namespaces for convenience. > so why …

Member Avatar for NP-complete
0
189
Member Avatar for norsalwani.shasa

What have you done so far? If you haven't, then start on something. We are not here to do your homework. We are here to help you in case you get stuck.

Member Avatar for JamesCherrill
0
196
Member Avatar for minimee120

You are NOT using StringTokenizer to merge the 2 arrays into the 3rd. You are using it to read the 2 arrays from a txt file. In that context, your strategy will depend on the way the data is distributed in that txt file. As far as the merging is …

Member Avatar for minimee120
0
267
Member Avatar for k22mac

> I have completed the objective Show us the **proof** (its DaniWeb's policy) and we'll be more than happy to comment on effectiveness and the rest...

Member Avatar for NP-complete
0
286
Member Avatar for javaprog200

Okay, first of all that apparently meaningless output is NOT representing "1" in any language, not even Klingon :) As James mentioned, the part after `[B@` is an *unique* ID for the array so every time you recompile your code its gonna print out something different. Now, `"1".getBytes()` returns a …

Member Avatar for javaprog200
0
217
Member Avatar for rachelmorg

Probably this is what you're looking for: public class numbers { public static void main(String[] args) { final int N = (args.length); for (int i = 0; i < N; i++) System.out.print(args[i]); System.out.println(); System.out.print('\"'); for (int j = 0; j < N; j++) { System.out.print(args[j]); // this will give a …

Member Avatar for rachelmorg
0
3K
Member Avatar for java123456

Think about it and come up with something yourself. We need to have proof of your efforts in order to help you. Show us what you've done so far and we'll help you from there...

Member Avatar for subramanya.vl
0
260
Member Avatar for thinkaboutyoueveryday

Dude, I told you once to stick to a single thread. Initially you had two threads for this...now you've made 3! As far as the calculations are concerned, why don't you calculate for some test cases and see if your code is giving you the same result or not?

Member Avatar for NP-complete
0
199
Member Avatar for MistaGeorge

**@MistaGeorge:** that's correct. A parent cannot inherit from subclass. Having said that, just for the sake of availability of a 2d array you may not need an inheritance structure. Share your class design or atleast tell us what you're trying to design so that we can guide you better. **@jalpesh_007:** …

Member Avatar for NP-complete
0
129
Member Avatar for thinkaboutyoueveryday

If your class has covered functions by now then please use them. Structure your code so that you don't mess up your main. Its like delegating works to helpers. Have separate functions for average, standard eviation and others (if you can think up some) and call those methods from inside …

Member Avatar for thinkaboutyoueveryday
0
224
Member Avatar for thinkaboutyoueveryday

We all can help...that's why we are here... but we don't help people who doesn't show any effort... and **we don't do your homework**. That's not DaniWeb. Try to think of some logic to solve the problem and we will certainly help you build up on it.

Member Avatar for thinkaboutyoueveryday
0
292
Member Avatar for TheMrPatrick

pakArtikel method is already receiving an article as a parameter. So why make a new Article? You can simply use this: public void pakArtikel(Artikel artikel) { Basket myBasket = new Basket(); myBasket.add(artikel); } If you really want to use a new article then those <suitable parameters> would be the various …

Member Avatar for NP-complete
0
561
Member Avatar for kingrev

You never calculated total time. The variable `TimeRequiered` simply calculates the time for each change and when you print the value outside the loop it prints the last value. To calculate total time first initialize the variable `TimeRequiered` to 0 at the beginning. Then change line# 44 to TimeRequiered = …

Member Avatar for deceptikon
0
258
Member Avatar for Atlanta15Braves

How does the Sorting.insertionSort() method look like? Is it from any standard API?

Member Avatar for subramanya.vl
0
371
Member Avatar for seeds

You are moving the temp to temp next before and then trying to print temp's variables! That's why you're getting all garbage! You should move line# 29 and 30 between line# 34 and 35. But that's not the only problem! You're reading off the first line using getline! The inFile …

Member Avatar for NP-complete
0
133
Member Avatar for singlin

What is your expected output and what are getting now? Please specify the error(s). A few observations at a glance: If you're using any standard compiler, your code may not compile. 1. Use `#include <iostream>` (no .h) 2. Same for `#include <string>` 3. Also, specify main to be returning int …

Member Avatar for ravenous
0
7K
Member Avatar for kbondarchuk

what errors are you getting? for writing main: [see this](http://lmgtfy.com/?q=java+method+calling+example)

Member Avatar for JamesCherrill
0
211
Member Avatar for karan.rks

for running an app you do not need a compiler. You can simply take out the .exe and share it. It'll run, but given the fact that you're using "Turbo C++" it might not run as you would've expected it to, on a few machines. A few advice: * Get …

Member Avatar for karan.rks
0
179
Member Avatar for jalpesh_007

Define a string somewhere and call it whatever... i called it str...then inside that loop use this: // for the last word, no comma afterwards... if (i == (aa5.length - 1)) { str = str + aa5[i]; } else { str = str + aa5[i] + ", "; }

Member Avatar for jalpesh_007
0
300
Member Avatar for brentr678

Which compiler? And which platform? It works as its supposed to in Visual Studio 2010 (i used the command line tool) on a Windows machine. I think, if you're on \*nix, along with that `cin.ignore(cin.rdbuf()->in_avail(),'\n');` you also need a `cin.ignore(cin.rdbuf()->in_avail(),'\r');` I'm not sure, but intuition tells me that it has …

Member Avatar for NP-complete
0
501