2,827 Posted Topics

Member Avatar for ScarWars9

> Also make sure your code is well structured and well documented! No! That's time better spent just getting the darned thing done, getting the points, and getting to the next problem. No contest I've seen cares about anything other than whether the code works. You aren't writing maintainable code. …

Member Avatar for Ketsuekiame
0
345
Member Avatar for diafol
Member Avatar for <M/>

On the "didn't like" side, put me down for not liking the Bar Rafaeli ad. Normally I find it a good thing when the not-so-good-looking guy has a shot with the hot babe. Not this time.

Member Avatar for <M/>
0
221
Member Avatar for bramprakash1989

[QUOTE=bramprakash1989;572363]i tried the following coding .it compiled without errors but gave absurd results during runtime. can u pls help me with it? #include<iostream.h> #include<stdlib.h> int main() { int i; cout<<"ten random numbers for the range 0 to 50"<<endl; for(i=0;i<10;i++) { cout<<rand()<<endl; return 0; } }[/QUOTE] You probably want the "return …

Member Avatar for dramatic
0
1K
Member Avatar for Ancient Dragon

Am I the only one having a problem following this thread? My X-Ray vision has gone bad, so I can't tell whether you guys are actually writing bad words that are getting filtered or just ####. I've seen bad-word filters where only a couple of the letters are blocked out …

Member Avatar for Reverend Jim
0
179
Member Avatar for VernonDozier

I am looking for a portable method of checking whether overflow has occurred when multiplying unsigned integers. The way I have always done it in the past is to turn my unsigned integers into uint64_t's, multiply, then create a uint64_t with a value of 2 to the 32nd power and …

Member Avatar for deceptikon
0
176
Member Avatar for JoeyJes

If you can print the first 500 prime numbers, you should be able to tweak the program to print ONLY the 500th prime number. You are printing in line 30. Do an if-test on the count variable. Execute line 30 ONLY if count is the correct value. In other words, …

Member Avatar for VernonDozier
0
11K
Member Avatar for dachy12

I think firstPerson meant to do this with his line 22. student kyle; kyle.input(); Create an object with the default constructor. Then fill it in with the input function, which should take NO parameters.

Member Avatar for dachy12
0
124
Member Avatar for mrnutty

There's nothing specifying that the numbers have to be positive. In that case, there are an infinite number of solutions, or since we're talking computer, "billyuns and billyuns" of them as our favorite astronomer used to say. v = w = x = 3. y and z and arithmetic inverses …

Member Avatar for mrnutty
0
119
Member Avatar for lewashby

Use the / and % operators to perel off and isolate digits. For example, if x = 12345678, to isolate the 345, you would first divide by 1000 to get rid of the 678 and end up with 12345, then to get rid of the 12 part, you would mod …

Member Avatar for lewashby
0
435
Member Avatar for Lardmeister

[QUOTE=fierykido;621801][COLOR="Red"]some say[/COLOR] that in 2012 december 21 we are going to enter a new era call the golden age and [COLOR="Red"]other says[/COLOR] that a new sun cycle has already started and the sun storm will be too big and somehow kill us.thats by the NASA i think but [COLOR="Red"]yet another …

Member Avatar for sneekula
2
2K
Member Avatar for <M/>

To get back to the actual scientific answer, I believe Ene Uran had it right a while back. An evolutionist is going to say that the egg came first. > Evolutionists: > An almost chicken laid the egg the first real chicken came out off. > Creationists: > God made …

Member Avatar for <M/>
0
389
Member Avatar for ThatBitchYeah

* Stick a "return 0" in there at the end of main. * Count your opening and closing brackets. Make sure you don't have a bracket mismatch. * Get rid of the stray semicolon after the final bracket.

Member Avatar for veducator
0
443
Member Avatar for <M/>

You're a high school freshman and you can do a four minute mile? That should be a U.S. record for the 15 to 16 year old age group. http://www.usatf.org/statistics/records/view.asp?division=american&location=outdoor%20track%20%26%20field&age=youth&sport=TF Scroll down. Record for 1500 meters (shorter than a mile) is 3:54.02 in the 15 to 16 year old category. If …

Member Avatar for <M/>
0
181
Member Avatar for FtKShadow

[QUOTE=FtKShadow;694512]I am trying to get my homework assignment to work for class, but I cant seem to get it. Heres the assignment. Seems not to bad doesnt it? Well I have been working for a while and it still isnt working for me. I enter lets say a 4 it …

Member Avatar for StefanRafa0
0
3K
Member Avatar for brock.holman.7

> the program shouldnt display the previous numbers counted. Do I take this to mean that there should be no output? Or should there be a countdown from 30 to 0, with a delay in between each iteration, then there is a "Screen Clear" and the new number is displayed? …

Member Avatar for Gonbe
0
137
Member Avatar for Hayati_mahamad

Forget the computer for a bit. Think of the algorithm. How would you do it with pencil and paper? What steps would you take? Write the steps out exactly. Follow the steps exactly to make sure they are right for all scenarios. Now go back to the code and make …

Member Avatar for Hayati_mahamad
0
195
Member Avatar for np2100

[QUOTE=SpecialeW;529887]hi, how can i make sure that when i ask a yes no question, i don't get rubbish for an answer. i have tried some while codes, but i seem to do something wrong, because when i execute the program i can enter anything i want... this is what i …

Member Avatar for Gonbe
0
340
Member Avatar for kimika

I'm reading the function name. I see a function called **addBook**, not **addBoooks**. Hence I am expecting to one book, not many. I am hoping this is the intent. One book, not twenty. I am confused by your description of what is occurring. You are entering something 20 times, not …

Member Avatar for VernonDozier
0
208
Member Avatar for caierhui

Code tags: [noparse] [code=JAVA] // paste code here [/code] [/noparse] Code looks terrible without them. This looks like a cut and paste of the assignment specification that someone gave you. What seems to be the problem?

Member Avatar for love1969
0
208
Member Avatar for chocolatesky

This is a matter of going line by line and changing the code to C++. All variables in C++ must have a type (i.e. int, char, string, etc.) and must be declared before you use them, so a good start might be to figure out what variables you need and …

Member Avatar for chocolatesky
0
139
Member Avatar for Prysm[VA]

You have not posted the declaration of dna1, so it's hard to say exactly where you are going with this. Regardless, having the brackets operator without an array index seems like an error. if(!dna1[].strand1){ Does the compiler let you do this? Then later you have this... cout<<"<"<<sizeof(dna1.strand1)<<">";} Is dna1 an …

Member Avatar for Prysm[VA]
0
456
Member Avatar for joshmo

[QUOTE=joshmo;877835]Ofcourse I can get to understand the logic..What I want to know is how i can get, say a given equation to integrate or differentiate a number, then change that logic, to JAVA code..is there any application or tool that can do this?[/QUOTE] Depends on the equation. A lot of …

Member Avatar for JamesCherrill
1
1K
Member Avatar for bhavna04

You need the ruler to break the candle in two. If you have the ruler, then Dani's solution has it covered. All these solutions only need ONE candle, yet we have two of them. Is the second candle a red herring? I think we can assume we have matches. Not …

Member Avatar for Reverend Jim
-1
265
Member Avatar for darkeclipse8

Consider using the "at" function instead of the [] operator and catching the error. You have a 2 dimensional vector. You need to find out which one gives the error. For some debugging... cout << i << '\t' << j << '\t'; cin.get(); cout << grid.size() << '\t'; cin.get(); cout …

Member Avatar for NathanOliver
0
409
Member Avatar for nekoleon64

What exactly is the problem? Possibilities might include... * Reading from file. * Writing to file. * Iterating through the list. * Swapping elementss that are out of order. * Not understanding the bubble sort itself. I see no non-commented out attempt to do a bubble sort, so obviously things …

Member Avatar for VernonDozier
0
1K
Member Avatar for Alex_

[QUOTE=Alex_;889004] I know there is another thread about the same subject but it's been dead for years. And nobody pays attention because of the silliness of the poster.[/QUOTE] There are a couple of THOUSAND threads regarding project ideas and as a result, most get ignored or flamed. However, I won't …

Member Avatar for JamesCherrill
0
316
Member Avatar for savinki

[QUOTE=savinki;620158]Hi, wt is the function that can use to count number of digits in a long integer? e.g. 12345678 -> 8 11 ->2 456 -> 3 6724 -> 4[/QUOTE] I don't know that there is a function that does that. You can do two things though. You can use the …

Member Avatar for Shahzad Ahmad
0
320
Member Avatar for Ranger86

Line 43 seems way off. I'll take your word that this compiles and runs, but even so, line 43 is definitely wrong. I'm assuming that line 43 is supposed to be a function call. However, it is NOT a function call. Function calls don't have the return type and parameter …

Member Avatar for VernonDozier
0
320
Member Avatar for celina1234

> i have to copy and rename the output file in each step so that they can be used in another program . "Copy" AND "Rename"? So you start with a file named a.txt and you are supposed to end up with what? one file? Two files? A file named …

Member Avatar for Adak
0
304
Member Avatar for wids101

Use the iostream library to read in data from the file into a card type and card number. How best to do that will depend on how the information is arranged in the file. A common way to set up a file would be to have two fields per line, …

Member Avatar for VernonDozier
0
240
Member Avatar for ppotter3

[code] void CoinChanger::getCoinChange(int &DollarCoin, int &QuarterCoin, int &DimeCoin, int &NickelCoin, int &PennyCoin) { this->DollarCoin = DollarCoin; this->QuarterCoin = QuarterCoin; this->DimeCoin = DimeCoin; this->NickelCoin = NickelCoin; this->PennyCoin = PennyCoin; }[/code] This is a set function, not a get function. Either rename it or make it an actual get function. [code] void …

Member Avatar for magadascar
0
2K
Member Avatar for VernonDozier

Is there still a "noparse" option? I tried posting the following in the C forum (let's see if it works here). Error message is as below. > The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or …

Member Avatar for riahc3
0
334
Member Avatar for jongiambi

struct Card { const string rank[13] = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}; const string suit[4] = {"Spades", "Hearts", "Clubs", "Diamonds"}; }; These are string arrays. The only purpose of them is to provide a quick way of converting a number from 0 …

Member Avatar for jongiambi
0
193
Member Avatar for rithish

The || operator is the "logical or" operator. the | operator is the "bitwise OR" operator. The |= operator combines the bitwise OR operator and the assignment operator. Thus the code above is equivalent to the code below. #include <stdio.h> #include <stdlib.h> int main() { int a=8,b=3; int c = …

Member Avatar for VernonDozier
0
142
Member Avatar for sannidhikumar99

> is it possible to print both statements of else If you are using the if-else clause as intended, either the code in the "if" part will execute or the code in the "else" part will execute, but not both. Now if the question is "Can I print 'Hello World'" …

Member Avatar for shashikumar s g
1
638
Member Avatar for jongiambi

Quite a few questions in this thread. Not sure which ones are still relevant and which are already solved. First, from an overall design, there is more than one way to do this. There are two main ways and you have mentioned them both. One is to have the Card …

Member Avatar for VernonDozier
0
8K
Member Avatar for jongiambi

Who wrote the code here? Is this code you have been given or did you write it? I've never seen this style of doing things. I always did it more like this... struct Student { string name; int id; int* markPtr; Student(); }; Student::Student() { markPtr = new int [100]; …

Member Avatar for VernonDozier
0
351
Member Avatar for tahity1

I'm searching your code for the phrases "pop" and "push" and not finding them. You can't have a queue or a stack without "push" and "pop" functions. You probably have them in the code, but are calling them something different. I see "malloc" in the hireEmployee function, so my guess …

Member Avatar for VernonDozier
0
125
Member Avatar for phorce

> Why I can't create a new Cat I'm searching for the phrase "new Cat" and not seeing it, except in a comment. Also, capitalization counts. "Cat" and "cat" are not the same... sc1->method("Cat"); if(something == "cat") Not directly relating to your problem, but still needlessly complicating your code is …

Member Avatar for L7Sqr
0
228
Member Avatar for sachi059

First off, I DO NOT get an error with the second program using gcc 3.4.5 on Windows XP. What error do you get? #include<stdio.h> int sum( int ,int,int ); int main() { int a=5,b=2,c=20; int d; d=sum(a,b,c); printf("c=%d",d); } int sum(auto int a,auto int b,auto int c) { return a+b+c; …

Member Avatar for deceptikon
0
876
Member Avatar for jghost

[code=cplusplus] void move( int n, char*s, char*i, char*d ) // s stands for source tower // d stands for destination tower // i stands for intermediate tower { if( n > 0 ) { move( n-1,s,d,i ); // move n-1 disks from source to intermediate tower cout << "disk " …

Member Avatar for angelbellz
0
2K
Member Avatar for mtm6042

I'll point out the obvious. One, this doesn't compile. Two, sortMe is not written. Am I correct in assuming that this is the code you have been GIVEN and the task is to change it so things work? If so, you're going to have to ask a specific question and …

Member Avatar for markaburlingame
0
158
Member Avatar for leesin

You can enter it on the command line or you can enter it when you ask the question and read it in with fgets or you change your program slightly and hard-code the path directly into your program (see below). Note that fgets leaves in a newline from the input …

Member Avatar for Ancient Dragon
0
152
Member Avatar for katsmiley

> // in binary 0011 0000 that is its 4th and 5th bits are set; Incorrect. 30 in binary is 00011110. Type in 4 and you get 1 << 4, which is 16 in decimal. 00000001 shift left 4 ---> 00010000. When you AND 00010000 & 00011110, you get 00010000, …

Member Avatar for katsmiley
0
642
Member Avatar for ntggl19

You've told us what it DOESN'T do. But what DOES it do? You'll need some newlines in your printf statements if you want things to print on separate lines. As for the main problem (which I assume is that the spaces are not weeded out), a space is a legitimate …

Member Avatar for ntggl19
0
201
Member Avatar for nitin1

I think I've found a way to do in at most six races. I have not totally convinced myself that it cannot be done with fewer, but I think the logic below proves all possible cases can be done in at most 6 races. Horses will be names H1 through …

Member Avatar for chris.stout
0
283
Member Avatar for Dani

Does everything have to be in one file and in one language? For example, what about, say, a C++ program that uses a class connecting to a Java program for the GUI. That's a main.cpp file, a .h class file, a .cpp class file, and the Java file, so that's …

Member Avatar for L7Sqr
3
1K
Member Avatar for Albino

Perhaps a namespace issue? Do you have either of these after the `#include <string>` line? `using namespace std;` `using std::string;` Alternately, you can replace `string str;` with `std::string str;`

Member Avatar for Ancient Dragon
0
169
Member Avatar for SAM2012

Same answer as on your other thread. To reiterate my points on that thread and possibly add some... * The question is quite vague. There are all sorts of simulators. I could give you advice on a priority queue using STL, then have you say you're not allowed to use …

Member Avatar for SAM2012
0
310

The End.