789 Posted Topics

Member Avatar for mattyd

Indentation (and whitespace in general) is important for anyone who ends up reading the code. That includes the person who wrote it. The readability of properly indented code is very much greater than unformatted code.

Member Avatar for vegaseat
0
323
Member Avatar for The Leprechaun

try putting [inlinecode]cin.get();[/inlinecode] before your return statement.

Member Avatar for may4life
0
86
Member Avatar for jessiegirl

We can help you, but first you have to help yourself. Try to solve the problem first and when you get stuck, ask a question; we won't do your homework for you. If you get stuck with designing your solution, at least post some pseudocode. If your code isn't doing …

Member Avatar for jessiegirl
0
106
Member Avatar for Brent.tc
Re: Help

1) Post some code. Unfortunately, crystal balls are a bit out of the budget, so we can't see what's wrong. 2) A 9-year old book is... well, almost antiquated. Consider getting a new one, since C++ has been standardized since your book was published. Some compilers may have problems with …

Member Avatar for WaltP
0
111
Member Avatar for asm_2

[quote=asm_2;263032]-If u have a slower I/O unit, then can the CPU execute instructions while waiting on slower I/O? -In this case, this type of optimization works differently for different I/O units... -So why are there no smarter .exe files that orders the instructions for your I/O-usage? -Whouldn't that be a …

Member Avatar for asm_2
0
109
Member Avatar for nimmi

You might reconsider using an int as your parameter type. You're limited to 10 binary digits, which leaves you with binary values from 0 - 1023 decimal (at least on my system). If that's fine for your needs, then so be it; otherwise you might consider using a long or …

Member Avatar for Infarction
0
127
Member Avatar for kissiwat

Also, you probably want to compare barometer to a range, rather than a specific value. Perhaps something like: [code] // assuming storm is low, and better weather is higher if(barometer <= storm) // ... else if(barometer <= rain) // ... else if(barometer <= fair) /* etc... */ [/code] The ranges …

Member Avatar for Infarction
0
111
Member Avatar for GreenDay2001

Since you didn't specify whether you understood, I'll try to explain it briefly. Say you have the following code: [code] class MyClass { public: int x, y; MyClass(int a = 0, int b = 0) { x = a; y = b; } };[/code] You can change the values with …

Member Avatar for GreenDay2001
0
89
Member Avatar for boujibabe

offhand I'd say it looks fine, though you may consider inputting each one and checking it separately. That way if the 2nd assignment is wrong, you don't have to input the other 3 again.

Member Avatar for ~s.o.s~
0
91
Member Avatar for jakestr15

[quote=Harkua;262888]do{ blah blah blah } while (yearcount!=5) That should help you a little.[/quote] Unless I missed something, the loop will go as long as [inlinecode]amount < famount[/inlinecode], assuming amount is updated to store the amount after a given time period.

Member Avatar for Infarction
0
90
Member Avatar for upside10

That doesn't look right. Each of statements in the innermost loop take constant (or close enough) time. What will change the execution time of this code is the loop conditions, both of which depend linearly on n. As they're nested, you have a situation of: [code]Outer loop, executes in O(n) …

Member Avatar for upside10
0
128
Member Avatar for ~s.o.s~

Spacial here too, but like WolfPack, I'm pretty sure I got all but maybe 1 of the objective questions right (I figure the "choose which is least like the others is somewhat subjective). I was clicking through the ads and noticed a small "No Thanks" link in the corner of …

Member Avatar for ~s.o.s~
0
165
Member Avatar for darkeinjel04

[quote=darkeinjel04;262256]I have Made a new program..but still there is a error declaration... i realy nid this program tomorrow so pls help me....re check [/quote] Why should we have to check your code? You should be able to tell if it works or not. And then if you have a problem, …

Member Avatar for Infarction
0
147
Member Avatar for The Dude

You answered 90% of questions correctly. I missed 5 and 8... not too bad, though I should know 8 (I've missed similar questions way too often)

Member Avatar for pistolsnipe16
0
173
Member Avatar for zac_haryy

Let's just look through your code and figure out why it give a backwards result: [code][COLOR=#0000ff]while[/COLOR]((input % 10) != 0) { number=input%10; input=input/10; [COLOR=#0000ff]switch[/COLOR](number) { // cases... } [/code] Each iteration of the loop takes the least significant digit and reads that one to you. What you're wanting is to …

Member Avatar for ~s.o.s~
0
101
Member Avatar for Laiq Ahmed

No. Unless 3n2/2 is supposed to mean (3n^2)/2, which is something of a deduction... Let's work this out from the inside out, starting with [inlinecode]printf("Hello World");[/inlinecode]. This'll execute in (approx.) constant time. Now we've got a loop. This loop will execute i times (0 to i-1). For each iteration of …

Member Avatar for Infarction
0
96
Member Avatar for Niklas

This sounds somewhat suspicious (very useful for a malicious program) but I could be wrong... I believe you could have the program open a file in the target directory, named as you wish the backup to be called. If the file exists, nothing's left to do. Otherwise you'd have to …

Member Avatar for iamthwee
0
156
Member Avatar for The Dude
Member Avatar for tlly

you might look at [URL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_strtok.2c_.wcstok.2c_._mbstok.asp"]strtok()[/URL] though I don't know that the MSDN page is particularly easy to understand... [edit:] if you need to use std::string, you could either use the .c_str() method or see if there's a split() function (I don't remember if it has one offhand).

Member Avatar for WaltP
0
107
Member Avatar for LieAfterLie

[quote=LieAfterLie]Okay, I've finished learning C++.[/quote]HAHAHA:lol: [quote=LieAfterLie]What can I do with it? Specifically, I want to do some graphics stuff, anything beyond iostream and fstream. What comes after C++? I know it does more than this. [/quote] Come up with a project. Once you know what you want to write, either …

Member Avatar for LieAfterLie
0
106
Member Avatar for waldis

I'd first off recommend using return types instead of pointers. Handling pointers like that (imho) just makes the code messier than it needs to be. You could do it with references instead of pointers as well. And instead of keeping endfile as a variable, just use [inlinecode]f.eof()[/inlinecode]. I'd also suggest …

Member Avatar for waldis
1
127
Member Avatar for VinceColeman

floating point numbers always have a degree of imprecision. A floating point value will never be equal to a whole number. You should check to see if it is within an acceptable epsilon from a whole number (or fractional value, if such a situation were to arise). [inlinecode](loanYears <= floor(loanYears) …

Member Avatar for FC Jamison
1
187
Member Avatar for Iqbal_h_a

Your code probably shouldn't compile. [inlinecode]add(int, int)[/inlinecode] is specified to return an int, but doesn't, which should raise a compile time error.

Member Avatar for Iqbal_h_a
0
119
Member Avatar for wheelz

Please don't [URL="http://www.daniweb.com/techtalkforums/thread55213.html"]double post[/URL]

Member Avatar for Ancient Dragon
1
104
Member Avatar for stupidenator

If you have [inlinecode]someIstream >> someString[/inlinecode] it will read up to the first whitespace. Try [inlinecode]getline(infile, name)[/inlinecode] after you get the 3 integers. (I haven't used C++ for a while, so I might be remembering getline wrong; if someone can confirm that I'd appreciate it.)

Member Avatar for stupidenator
1
171
Member Avatar for wheelz

[code]switch(value) { case possibleValue1: // do something break; case possibleValue2: // do something break; /* ... */ default: // value wasn't any of possibleValue[1,n] // do something }[/code] Post some code, or some sort of attempt if you want more help ;)

Member Avatar for Infarction
1
283
Member Avatar for Klitzy

First start out with a simple skeleton code: [code]class Main { public static void main(String [] args) { } }[/code] Now, let's think about what we need to do. We probably should prompt the user to enter the numbers (even though you know it takes 2 numbers, prompts make it …

Member Avatar for iamthwee
0
150
Member Avatar for Maux

The easiest way would be to put a big loop around the main part. You could have your menu contain an extra option to quit, and just keep doing calculations until they enter that option.

Member Avatar for rinoa04
1
128
Member Avatar for the.future.zone

[code] #include<stdio.h> [B]int[/B] main() // main's return type is int { /* ... */ b= m%2; // I'm assuming you mean [B]n%2[/B] while( b!= 0) // this will check if [B]n[/B] is even or odd. if it's even, the loop will be skipped. See below. [/code] [quote="the.future.zone"] The loop has …

Member Avatar for rinoa04
1
113
Member Avatar for Klitzy

It would be nice if we knew what the problem was (saves us time figuring out where to start).

Member Avatar for Infarction
0
87
Member Avatar for FrstratdProg

basically, you should put code segments between [noparse][code] and [/code][/noparse] tags. It looks like this: [code]Your code will be in here and formatting will be preserved so we can all read it[/code] If you want to point out a specific line, you can use [noparse][inlinecode] and [/inlinecode][/noparse], which looks something …

Member Avatar for Dani
1
100
Member Avatar for govinda.attal

[quote=govinda.attal;252142]This code does compile and generates an exe file...When I went thru disassembly, I found nothing useful in it...There were no nops in it. First of all our basic coding principles say that it should give a compiler error... compilers like msvc, gcc simply pass without giving any error or …

Member Avatar for andor
1
205
Member Avatar for insamd

First off, lets look at two code segments. The first is your original while loop, the second is writeTotal. [code]/* ... */ // the while loop: while (!inStream.eof()) { writeTotal(letterCount); } /* ... */ // writeTotal void writeTotal(int list[]) { int index; for(index=0; index<26; index++) cout << static_cast<char>(index+static_cast<int>('a')) << "(" …

Member Avatar for insamd
1
453
Member Avatar for ariyan

I'd agree with Grunt. But to make my post somewhat meaningful, I though I'd also point out that you made b of type [inlinecode]unsigned long double[/inlinecode]. I'm thinking that you don't want a floating point value if you're doing integer operations (especially if you're using bitwise operators).

Member Avatar for ariyan
1
132
Member Avatar for himanjim

[inlinecode]~a[/inlinecode] flips the bits in a, but doesn't save the result anywhere. On the next line, a is still equal to 0xffff. 0x marks that the value is written in hexadecimal (simlarly, a number preceded by a 0, such as 024, is written in octal). Lastly, and unsigned int is …

Member Avatar for Dave Sinkula
1
539
Member Avatar for CurtisBridges

[quote=Anonymusius;251672]But in small programm's like this doesn't it really matter, but in large programm's is it an bad habbit.[/quote] A bad habit is a bad habit, no matter what size the program is. Sure, it can be easier for a small program, but that doesn't change things. Same could be …

Member Avatar for CurtisBridges
1
121
Member Avatar for cvr-grl

Well, you've got a good start. Couple of tips: a) use [noparse][code] and [/code][/noparse] tags when you post code, so that formatting is preserved. Makes your code more readable for those trying to help ;) b)your [inlinecode]public boolean trial[/inlinecode] should not be inside main. Make sure there is a closing …

Member Avatar for jwenting
0
103
Member Avatar for Antiparadigm

[quote=Antiparadigm;251446]The line: [code] jfWindows.setDefaultCloseOperation(EXIT_ON_CLOSE); [/code] Has to be implemented in an action listener right?[/quote] You can just put it in main once you've created the JFrame. It's just a call to a method, afterall ;)

Member Avatar for Antiparadigm
0
142
Member Avatar for Jafet
Member Avatar for Infarction
0
173

The End.