2,827 Posted Topics
Re: Please re-post with code tags and formatting. [noparse] [code] // paste code here [/code] [/noparse] | |
Re: Re: Formatting. It's very important. Get Visual C++ and let it format for you. Let it "detabify" for you too and everyone's happy. Regarding code like this: [code] void initialize(int countFemale, int countMale, float sumFemGPA, float sumMaleGPA) { float FemGPA = 0.0; float MaleGPA = 0.0; countFemale = 0; countMale … | |
Re: [QUOTE=Miyamoto;610946]Checking the entire vector will take O(n) time. What that means guys?[/QUOTE] The base is base 2 when you refer to logn or nlogn. Thus if n = 16, O(logn) = 4 since 2^4 = 16. Searching a balanced binary tree often takes O(logn) time since the depth of a … | |
Re: [QUOTE=Hugers;801290]Hello, Is there any way to eliminate debt by taking any short term loan?[/QUOTE] This is a contradiction in terms. If you take out a loan, you're in debt. If the question is: Can I take out a loan that isn't due till next month in order to pay my … | |
Re: Here's your code formatted and with the excess spacing removed. It's much easier to follow: [code=C++] #include <iostream> using namespace std; int main() { int checks = 0; double balance,fee; cout << "Hello What's Your Balance? "<<endl; cin >> balance; if (balance <400 && >=0 ) { cout << "HOW … | |
Re: You haven't gotten a response because the question is a bit vague. You'll have to say what type of robot it is, the exact type of programming you'll be doing, etc. It's pointless to just learn C and C++ because you'll be learning things that you probably don't need to … | |
Re: Not sure what you are trying to do. You'll have to provide a more in-depth example. Here's a link to an example on how to overload the + operator and how to call it. Scroll to the bottom. [url]http://msdn.microsoft.com/en-us/library/5tk49fh2%28VS.80%29.aspx[/url] | |
Re: [QUOTE=lynneh3979;1373503]I need to add "x" to every other letter in the array so that I can print out Ax Cx Ex etc. I do not know how to append the "x" it he letter in the array and write it to another array.[/QUOTE] If you need to append letters, then … | |
Re: Get rid of the word "double" in line 10: [code] cout << double grossPay(a,b); [/code] Change it to this: [code] cout << grossPay(a,b); [/code] That solves that problem but you have quite a few other problems in your grossPay function. For instance, what is this line supposed to do? [code] … | |
Re: [code=C++] int value1 (int a[]) { int i; cout << "Enter a integer less than 30 "; cin >> a[i]; i=0; i < counter-1; i++; return a[i]; } [/code] No clue what you are trying to do here. Line 6 doesn't make any sense to me. Is this a for … | |
Re: One, make g a global constant (i.e. define it BEFORE, not INSIDE main). Then move your code outside of main and call it from main. You already have the formula: [code] d = ((.5)* g * s * s); [/code] Make a function out of it: [code] double getDistance(double s) … | |
Re: I just helped someone via PM (I know, not supposed to do that ;)). The same post applies here, so I'll recreate it verbatim. Here's the way it works. [code] // #include statements using namespace std; // function declarations (include semicolons) int main() { // function calls return 0; } … | |
Re: And...? What's the question? Line 15 is a seg fault, line 17 has the quotes in the wrong spot and the slash backwards, and everything stops after line 18. I assume there's more? | |
Re: Well, how about reading in the input and passing it to rightPrime. Make isPrime just return 1. Make rightPrime just call isPrime and return the value. Then harness that return in main and display a result. That gives you a skeleton. Then write isPrime and get it working. Then write … | |
Re: It compiles and runs fine for me. What's the exact error? | |
Re: General pseudocode: [code] float userInput; bool goodData; do { goodData = true; // ask the user for input, stick the input in userInput // test whether the user input is good if(/* test for good input fails */) { // display error message goodData = false; } } while(!goodData); // … | |
Re: You need to: [LIST=1] [*]Use code tags. [*]Take whatever you professor gave you and turn it into your own words. We hsve no idea, for example, what Appendix 3 is, so don't refer to it. [*]Tell us what the problem is. You're stuck, but where? [*]Does it compile? Does it … | |
Re: To take code out of main and put them in functions, start with what you have: [code] #include <iostream> #include <iomanip> #include <cmath> using namespace std; const double pi = 3.1416; int main () { float x1, x2, y1, y2; float distance, circumference, area, radius; cout << "Enter the x … | |
Re: [QUOTE=Greywolf333]Hey all, I've been using Visual Studio for a long time. Lately though, after I build an executable successfully, it won't let me build it again for a solid 60 seconds or so, claiming that, for example, test.exe is still in use (when it's clearly not, because if I go … | |
Re: >> What will happen if I run a program with an infinite loop? I am very reluctant to run such a program because I am fearful of doing something I can't undo. I doubt there's anything to "undo". If you run a program with code like this: [code] while(1) { … | |
Re: Exact same behavior for me as you got in your first post. It has NOT fixed itself for me. I've seen it a lot with several ads. | |
Re: [QUOTE=Rickay;]I am using headers to include all of the functions, but I cannot wrap a loop around an entire program that is contained in more than one file. But I figured it out, I made a duplicate function called main1() and included the same syntax as that in main(), and … | |
Re: [code] char* charArray[3]; strcpy(charArray[0],"wn"); strcpy(charArray[1],"chair"); strcpy(charArray[2],"-over"); [/code] You allocate memory for the pointers to the strings, but not for the characters themselves. Try replacing replacing the first line with this: [code] char charArray[3][20]; [/code] Make sure none of your strings have more than 19 characters though! | |
Re: I have to admit that I used to play a decent amount of Grand Theft Auto and its variants. I'll also confess that, while I normally play the part of a G.I. in video games, I've occasionally played on the Nazi side. Playing for the Taliban side seems a bit … | |
Re: Hi, Do you have a specific question on how to code these algorithms in Java, or is this a game theory question where you have some algorithms but aren't sure how to use them to solve your puzzle/problem? In other words, in order to offer you help, do we need … | |
Re: You never attempt to read a file. You read in a filename, but there is no attempt to read the file. [code] char filename; [/code] filename needs to be a string, not a char. [code] cin >> filename >> endl;[/code] Don't read in the endl. Just read in the filename. … | |
Re: Tackle the math first. You need to understand the algorithm first. That's an algorithm problem, not a programing problem. It's also pencil-paper or better yet, whiteboard since you'll be erasing a lot. Two cells are disjoint if you can't get from one to another. The trivial way to do this … | |
Re: [code=cplusplus] #include <iostream> #include <string> using namespace std; int main() { double num; bool prime; cout<<"This is my program check if a number is a Prime number, also a Perfect Number!"<<endl; cout<<"Enter a number between 1 and 1000 "<<endl; cin>>num; if ((num<=0)||(num>1000))//SETTING UP THE FIRST ERROR MESSAGE { cout<<"Error, Please … | |
Re: I don't see a << operator for your class. You need one. There are some good threads on the subject on Daniweb. Here's one. [url]http://www.daniweb.com/forums/thread137909.html[/url] | |
Re: Line 43. You prompt the user for input, then immediately exit the program. Presumably there should be a cin statement after line 43 and before line 45, then you'll want to do something based on what the user entered. | |
I forgot I wasn't logged in and proceeded to write a really fantastic post, if I do say so myself. To no avail. I "submitted" it, but was told I wasn't logged in. Reasonable enough, but then I couldn't get back to the post. Two possible solutions. [LIST=1] [*]Have the … | |
Re: As with many such questions the answer is "it depends". You have to start with the group you are dealing with. I've had disappointing results in robotics projects, mainly due to a lack of common agreement as to what the commitment level was. Some people thought it was a cool … | |
Re: You don't pass data from one array to another. You can pass an array to a function. That array is the address in memory of the first element. One way or another, for the function to use the array, it needs the address where the array is located. There are … | |
Re: I don't see the math bbCode. I think the OP means 15 = 1^2 +1^2 +2^2 +3^2 = 1 + 1 + 4 + 9 = 15 where ^ represents raising to a power. To the OP : Pencil and paper till you see a pattern. Get the math down … | |
Re: [QUOTE=Suzie999]Is it possible to password protect a dll at compiletime. Please excuse my noobness, but let me explain what I mean. You app an runtine makes a lot of calls to a function in a library so it opens it and keeps it open for the duration your app is … | |
Re: >> The problem is that there are some things that i don't know what it stands for or what it does Like what? If you don't understand the formulas, then a math/statistics forum might be a better place to ask. Google "standard deviation example" and you'll get thousands of hits. … | |
Re: By now if no one has told you how to use code tags, I will: [noparse] [code] // code here [/code] [/noparse] [code] #include <iostream> using namespace std; int main() { int x,y; char z; char q; cout<<"please input an expression (two numbers and a function) to be solved, when … | |
Re: I answered your last thread. If the current thread is here, mark the old one closed. Way too many unnecessary brackets, but that's not the problem. The problem's simple. Replace the comma at the end of line 10 with a semicolon and recompile. Always go to the FIRST error and … | |
Re: You have a two dimensional array, so you need to dereference it twice. [code] arr[i] = (char)i; // wrong. arr[i] is an address, not a char. arr[i][0] = (char)i; // right. now it's a char. [/code] | |
Re: Please use code tags: [noparse] [code] // code here [/code] [/noparse] Try this. [code] bool withdraw(double amt, int pin){ if (amt <= bal) return true; if(amt >= bal) return overDraft(pin); } bool overDraft(int pin){ if (pin ==123) return true; if(pin==456) return false; if(pin==789) return true; }[/code] | |
Re: No, there is no possible way to switch on a string. But you aren't even trying to switch on a string. You have x defined as an int. Also, don't confuse single and double quotes. Strings use double, not single quotes. Perhaps you want something like this? [code] int colortonumber … | |
Re: You're stuck at the loop section? You don't HAVE a loop section. If you mean "I can't figure out how to CREATE the loop section", say that. Presumably you need help with this section? [quote] FOR count = 1 TO number of decades DO FOR inner count = 1 to … | |
Re: Am I the only one who STILL doesn't understand what the requirements of this assignment are? I've been following this thread. Apparently initially everyone was as confused as I was, but then a few posts back, everyone else "got it". I'm still as confused as I was twenty posts back. … | |
Re: You have several tasks: [LIST=1] [*]Tell the user exactly what they need to enter for input. [*]Verify that the input is good. If not, give them an appropriate error message and prompt them again. [*]Convert THEIR input into something that you can stick into a formula and calculate. [*]Give the … | |
Re: Some possibilities: [LIST=1] [*]Data is read in incorrectly. [*]Data is sorted incorrectly. [*]Data is displayed incorrectly. [/LIST] Stick a call to your display before and after the sort. If it's all 0's BEFORE the sort, then ignore the sort function. If it looks good BEFORE the sort, but after the … | |
Re: [QUOTE=towhidd;617470]i want to know how to dispaly a series of number. Supose an user input a number(40). The progrme will generate and display like this way: 1-prime 2-not prime 3-prime 4-not prime 5-prime 6-prime upto 40-prime plz solve my proble. I will b grateful to u.[/QUOTE] One, you've already asked … | |
Re: Well, first you have to write the programs themselves. Then set up some counters for the number of operations and do some time calculations. After that, start plotting and find a math equation. Note that you might need something more precise than seconds. [code] // global int numOps; void SomeRecursiveRoutine(int … | |
Re: Word is "abcdefghij". Valid indexes are 0 through 9, inclusive. You want to pick two indexes and swap the letters. [code] int index1 = /* random number */ int index2 = /* random number */ // swap char temp = word[index1]; word[index1] = word[index2]; word[index2] = temp; [/code] First and … | |
Re: Frankly I think this is a FANTASTIC way to use one's time. If I had the time and the resources, I'd try to use my time the same way. It looks more interesting than MY job. | |
Re: Not sure what your approach is, but you need to either change the data members in your class or you need to have more class object. Right now you have one object and it stores one character and one long. You need one character and one long for each ASCII … |
The End.