2,827 Posted Topics

Member Avatar for valkerye

[code] infile >> value; while (!infile.eof()) { outfile << value; outfile << endl; infile >> value; } [/code] You have [ICODE]infile >>[/ICODE] reading one number per trip per the loop, plus once at the top. If you have this file: [code] 7.8 7.6 8.9 [/code] how many trips through the …

Member Avatar for VernonDozier
0
733
Member Avatar for new programer

[QUOTE=new programer;1017463]Howdy Folks! I've been asked to write a program that reads in an interger N and calculates The factorial ... I wrote this yesterday but it does not seem to work .. here's the code : [CODE] #include <iostream> using namespace std; int main() { int i=0; int s=1; …

Member Avatar for warbird43
0
135
Member Avatar for ross42111

Any casting you do to get this to work will just be a band-aid to cover up a problem. This program doesn't need any casts. Lines 63 and 64 appear to me to be impossible to reach. Line 22 - season is uninitialized, but you use it in a comparison …

Member Avatar for VernonDozier
0
119
Member Avatar for ENCHTERP

You don't need to copy anything to get a row. You just need a pointer. The program below reserves space for and initializes 12 integers. Row 2 is integer indexes 8 through 11. "Copying" implies changing the memory at certain locations. That isn't necessary here. The row2 array simply points …

Member Avatar for VernonDozier
0
8K
Member Avatar for VernonDozier

Everyone has way less than before, except for newbies, who appear to have the same. I remember Ancient Dragon starting a thread requesting a way that he could possibly neg rep someone without placing them in an eternal red zone. Makes sense. Everyone deserves to make a mistake and learn …

Member Avatar for jbennet
1
646
Member Avatar for samaru

[QUOTE=reverence;1014461]just newbie here and am trying to learn some of this regarding to my course aa minor in com sci. ..[/QUOTE] "Community Introductions" would be the proper forum for posts like this. Welcome!

Member Avatar for happygeek
0
2K
Member Avatar for NinjaLink

Please repost the expected and actual output in code tags. All spacing gets stripped out otherwise so we don't know if that happened here. I suspect so because neither figure looks like a diamond. The expected output looks like a half-diamond. Is that what you want?

Member Avatar for VernonDozier
0
96
Member Avatar for Artamos

[QUOTE=Artamos;1013687]First my skill levels: I was over the moon when a friend donated his Trash80 to me, complete with manuals, oh so many years ago.. I got a glimpse into the PC world and later embraced DOS programming..:) As windows came into the picture I left behind my 'boyhood' knowledge …

Member Avatar for Artamos
0
113
Member Avatar for VernonDozier

I've googled this and it looks to me like what I am trying to do is impossible. I'm trying to write a [ICODE]Display[/ICODE]function that can take different parameters and call the appropriate function based on those parameters (i.e. function overloading). I've read that C doesn't allow this, but I figured …

Member Avatar for VernonDozier
0
111
Member Avatar for dokinah1

This isn't a code snippet, this isn't C++, get rid of the HTML code, and this is way too much code for someone to go through without a much more precise pinpointing of the problem by you. [LIST=1] [*]Post in the correct forum. [*]Post as a regular thread rather than …

Member Avatar for network18
-1
199
Member Avatar for LaurenR

There's more than one way of splitting it up. Here are two of them: [code=text] 1->2->3->4->5->6->7->8 becomes 1->2->3->4 and 5->6->7->8 or 1->3->5->7 and 2->4->6->8 [/code] The first way requires you to know how many elements you have in the first list before splitting the list. Go through half of them, …

Member Avatar for VernonDozier
0
514
Member Avatar for jdrei

Here's a code snippet I wrote a while back that you might find useful. It isn't the only way to do it, but it has a nested loop and takes advantage of some efficiencies such as not testing 4, 6, 8, ... as the previous poster mentions. Nor will it …

Member Avatar for VernonDozier
0
2K
Member Avatar for amit.kumar

If you need help, then this isn't a code snippet. Please post as a regular thread.

Member Avatar for mrnutty
0
110
Member Avatar for NICEGUY123

[QUOTE=NICEGUY123;1012835]I need some help passing a array of integers into a hash table by chaining. So if the array is filled it that location it will go to a linked list of the index. any ideas on how to get this done. This is what i have so far. [CODE]chainFunc(int …

Member Avatar for VernonDozier
0
94
Member Avatar for jupitertrooper

You isolate a character int a string using the [] operator. [code] string input = "yes"; char firstLetter = input[0]; if (firstLetter == 'y' || firstLetter == 'Y' || firstLetter == 'n' || firstLetter = 'N') cout << "Input is valid\n"; else cout << "Input is invalid.\n";[/code]

Member Avatar for jupitertrooper
0
132
Member Avatar for shakunni

I've never heard of "rt" mode. Are you sure you didn't intend the mode to be "r+"? Check errno and see what the problem is. Here's the man page for fopen. I see no "rt" option on it. It also has the possible error flags. [url]http://www.manpagez.com/man/3/fopen/[/url] But since you're using …

Member Avatar for VernonDozier
0
169
Member Avatar for vileoxidation

Since you haven't provided the printInfo function, we can't see whether anything is wrong with it. My first advice would be to just have printInfo () display "Hello World" and return. If you don't get that output, then it's not even being called and that narrows down your problem. If …

Member Avatar for triumphost
0
164
Member Avatar for genDisarray

You call srand ONCE during each program, then you call rand to generate the numbers. If you want ten numbers, call srand (time(0)) once at the very beginning of the program, then call rand () ten times: [code] srand (time (0)); // first line of program for (int i = …

Member Avatar for vmanes
0
832
Member Avatar for triumphost

I'm not a Windows programmer, so I can't help debug, but is there anything in the program that requires you to use all of these Windows-specific headers? Will the regular C and C++ standard libraries not do what you need? I'm pretty sure nothing but Visual Studio uses "stdafx.h", and …

Member Avatar for triumphost
0
769
Member Avatar for sebassn

[QUOTE=ayeshawzd;1009927]now u can try n no thanks needs[/QUOTE] [LIST=1] [*]Post has nothing to do with the thread. [*]Original poster has shown no effort, so you shouldn't be fixing the code from another poster, even if you were posting on the correct thread, which, again, you are not. [*]No code tags. …

Member Avatar for sebassn
-1
114
Member Avatar for th3learner

This isn't a code snippet. If possible, please change the thread type to a regular old thread as opposed to a code snippet. The && operator doesn't work that way. You want something like this: [code] if (a > b && a > c) cout << "First value is the …

Member Avatar for th3learner
0
148
Member Avatar for bliya123

In addition to post 2, you still have problems. I'm not entirely sure what they are, but if x1, x2, y1, y2, z1, and z2 are supposed to be the same values at the end of the first function as they are at the end of the second function, they …

Member Avatar for VernonDozier
0
211
Member Avatar for sebassn

I don't know what you're doing with the posts, but preview them before you post. You have some odd tags. Perhaps you pasted html code rather than plain text code and pasted it here. Hit "Preview Post" to make sure things look right, then fix the post if there's something …

Member Avatar for VernonDozier
-4
106
Member Avatar for GooeyG

The compiler doesn't like the fact that you are initializing this array between lines 10 and 47. It wants you to do the initialization after line 47. Is this a static array? If not, you may want to initialize it in the constructor. Anyway, check out this link. I don't …

Member Avatar for VernonDozier
0
147
Member Avatar for why1991

There are a lot of problems with both the algorithm and the program's implementation of the algorithm. Let's start with primes[]. What should primes[] eventually contain if I enter a max of 25? Is primes[] supposed to contain all prime numbers less than 25? The first 25 prime numbers? Regardless, …

Member Avatar for VernonDozier
0
175
Member Avatar for Cheesy74

Sounds like there is a lot of math involved. If you refer to a theorem, you should link it: [url]http://en.wikipedia.org/wiki/Separating_axis_theorem[/url] Is this a math problem or a problem with the implementation of the math in Java (i.e. do you understand the theorem and know how to use it successfully, but …

Member Avatar for VernonDozier
0
362
Member Avatar for Mr Bin

One, it's [ICODE]int main ()[/ICODE], not [ICODE]void main ()[/ICODE]. Two, we need an input file. Three, what's the point of having a program with no output, either to the screen or to a file? How do you test it? If there is output, I missed it. Four, what's the question?

Member Avatar for VernonDozier
-1
98
Member Avatar for vs49688

[QUOTE=vs49688;1007243]Hey, Does anybody know of a way to generate a random number without using srand(time(NULL)). I need it for a program I'm writing. srand(time(NULL)) is seeding it based on the computer's clock, but it's only accurate to the nearest second, so it's not fast enough. I've had to put Sleep(1000) …

Member Avatar for mrnutty
0
108
Member Avatar for NinjaLink

[QUOTE=NinjaLink;1005026]This is the latest code that I have to duplicate 4 words in my list. I am currently experiencing "base operand of '->' is not a pointer errors", and I can't figure out how to fix it. Am I going in the right direction in duplicating 4 words in my …

Member Avatar for NinjaLink
1
217
Member Avatar for Deva.VG

[QUOTE=Deva.VG;1007230]Can I get the java code for online transaction to embed it with the webpages[/QUOTE] We understand that you're an important person and you have a busy life and you thus have neither the desire nor the time to put effort into this, but please realize that you have to …

Member Avatar for VernonDozier
0
96
Member Avatar for beshoyatef

Try setting your Pawn panels to a background color of green or something and see if anything that's displayed ends up being that color. If it isn't displayed, it can't be clicked. You have this line: [code] new Pawn(); [/code] which creates Pawn objects, but these objects never get displayed? …

Member Avatar for VernonDozier
0
78
Member Avatar for wyett

You need to post more code. We need to see the declaration of mGPA. Presumably it's a double, float, long, int, something like that, so when you enter "x", >> can't do anything with it and it has this "x" in the stream that it must get past before it …

Member Avatar for wyett
0
158
Member Avatar for maddy1985

Ancient Dragon already explained the way it works here in your last thread. Post some code (in code tags) that shows you've made an attempt, then ask a SPECIFIC question:

Member Avatar for VernonDozier
0
78
Member Avatar for sweebez

Your comment in line 7 is revealing. It says that the ending bracket ends the function isAlive (). It does not. It ends the if-else statement. You need ANOTHER ending bracket after that to end the isAlive () function. Right now you have your toString () function INSIDE of your …

Member Avatar for 0805638
0
637
Member Avatar for DC257209

Line 29 won't work. getline reads a line, so you should have this (no = sign): [code] getline (cin, line); [/code] If you then want to convert line into an integer, use atoi or strtol. These work on C-style strings, not C++ style strings, so convert line using c_str (); …

Member Avatar for mrnutty
0
145
Member Avatar for TaP1227
Member Avatar for TaP1227
1
134
Member Avatar for lotrsimp12345

Lines 99 - 129 - This looks like an infinite loop to me if you enter "-1". Lines 101 to 119 are skipped since "-1" isn't 10 characters long. The "if" condition in line 122 isn't true since accountNumber is "-1". What code do you want to execute if accountNumber …

Member Avatar for lotrsimp12345
0
195
Member Avatar for whiteyoh

[QUOTE=whiteyoh;1005394]Hi All, I have an array of 3 objects stored in cdList. Because I have now added them to an array, the usual method of displaying no longer works: [code]System.out.println(cd1.getArtist() + " " + cd1.getTitle() + " " + cd1.getCost());[/code] My questions are...... how would i amend to output the …

Member Avatar for whiteyoh
0
82
Member Avatar for whiteyoh

Define "value". Your CD class doesn't have a data member called "value". It has "Cost". Is that "value"? If you're adding up all the Costs, you can have a static variable in your CD class. You can also have one for the number of CD's. Something like this: [code=JAVA] public …

Member Avatar for whiteyoh
0
287
Member Avatar for whiteyoh

Having a static Collection of CD objects is fine and will work, but I see nothing in your requirements that would need more than I posted in my post in your last thread (a static integer and a static double, adjusted during each call to the constructor). Did you run …

Member Avatar for VernonDozier
-1
101
Member Avatar for trac15

[QUOTE=trac15;1004282]Thank you! But the write function doesn't seem to work or i am going in the wrong direction. can u help me[/QUOTE] Post poly.h and poly::write (). We have no idea what you might be doing wrong unless you post the code.

Member Avatar for iamthwee
-1
161
Member Avatar for thisisnot232

Repost in code tags: [noparse] [code=JAVA] // code goes here [/code] [/noparse] Without them, we can't see the indentation and we have no idea what lines 27 and 43 are.

Member Avatar for VernonDozier
0
100
Member Avatar for Bemani_lover

[code] *double getSales() [COLOR="Red"]is passed the name of a division[/COLOR]. It askes the user for a division's quarterly sales figure, validates the input, then returns it. It should be called once for each division. *void findHighest() [COLOR="Red"]is passed the four sales totals[/COLOR]. It determines which is the largest and prints …

Member Avatar for VernonDozier
1
167
Member Avatar for Daithi

There are a few ways of calculating the standard deviation, some more efficient than others. Say you have five points: 1,2,3,4,5 Calculate the mean, which is 3. Now go through the points one at at time and get the differences: [code=text] 1 - 3 = -2 2 - 3 = …

Member Avatar for VernonDozier
2
141
Member Avatar for gibson.nathan

This program should really have some functions. You have a few tasks here: [LIST=1] [*]Display the options. [*]Ask the user for the the number of characters. [*]Ask the user for the option. [*]Make sure the person enters legal values for both. If not, give an error message and prompt the …

Member Avatar for VernonDozier
2
1K
Member Avatar for Kimmelivim

One, use code tags: Two, what's the question? Three, don't use `void main ()` even if your compiler lets you get away with it. Use `int main ()`.

Member Avatar for vmanes
-2
114
Member Avatar for blamp

There isn't too much to a boolean function. They return true or false based on whatever. Here's an example of a boolean function that returns true if both numbers passed to it are the same, false if they are different. You'll need to change it to accept the parameters you …

Member Avatar for blamp
-2
143
Member Avatar for ahihihi...

[QUOTE=NicAx64;845977] Most of them are using Microsoft windows. And when I offer them a Knoppix CD they even refused to just boot from that live CD. and when I suggest them about a open source project instead of using visual C++ they totally refused .so now we are doing a …

Member Avatar for Lardmeister
1
225
Member Avatar for virtualmisc

[QUOTE=virtualmisc;1003432]I want to find the product of two matrix using a function without using for loop? Help is really appreciated.[/QUOTE] Why don't you want to use a for-loop? That would be the easiest way. Any for-loop can be converted to a while or do-while loop, and vice versa. You're looking …

Member Avatar for mrnutty
-2
111
Member Avatar for tomtetlaw
Member Avatar for VernonDozier
0
146

The End.