96 Posted Topics
Re: [code] //function prototypes void rev_str(); double Mean(const int Data[5][4], int, int); void frequency(const int Data[5][4], int,int); // main int main() { . . . return 0; } // functions . . . [/code] | |
Re: Side note: You only need to seed the random number generator once to use it for the application. [code=C+] // . . . int main() { srand((unsigned)time(0)); // . . . } // . . . [/code] | |
Re: If you leave it as is, it will only perform 10 repetitions of the loop, including invalid inputs. Then you'd only get the first 10 - (number of errors) even integers in your summation. My suggestion is this: [code=C++] for (int ctr=1; ctr<=10; ) { cout<<"Enter a number"<<endl; cin>>num; if … | |
Re: Wheres the closing brace for your main function? [code=C++] for (i=1;i<=blankCount; i++){ cout <<" \t"; } for(i=1; i <= totalDates; i++){ cout << i << "\t"; dayCount++; if (dayCount==7){ cout << "\n"; dayCount=0;} } [/code] Ok... so for instance April... the output looks like this: [code] I will display the … | |
Re: What is the question... your code compiles and does everything it's supposed to? | |
I have three files (myClass.h, myClass.cpp, and main.cpp) [code] // // myClass.h #ifndef MYCLASS_H_ #define MYCLASS_H_ template <class element_type> class myClass { public: myClass(); ~myClass(); }; #endif /* MYCLASS_H_ */ [/code] [code] // // myClass.cpp #include "myClass.h" template <class element_type> myClass<element_type>::myClass() { } template <class element_type> myClass<element_type>::~myClass() { } [/code] … | |
Re: [code=C++] int score; char grade; // read in total score cout << endl; cout << "Enter total score (float, must be <= 100): "; cin >> score; if (score >= 85) grade = 'A'; else if (score >= 75) grade = 'B'; else if (score >= 65) grade = 'C'; … | |
Re: wrap it in braces { blah } Also, in your if statement, I think you're missing an else? [code] if ( ( i == 2 ) or ( i % 2 != 0 ) ) { p = i; } [COLOR="Red"] else // ????[/COLOR] { for ( int j = … | |
Re: delete Operator (C++): [url]http://msdn.microsoft.com/en-us/library/h6227113(VS.80).aspx[/url] Dynamic Memory: [url]http://www.cplusplus.com/doc/tutorial/dynamic.html[/url] | |
Re: [code]inFile.open("C:\\hw_5-1_ext1.txt");[/code] C:\hw_5-1_ext1.txt must exist and be in the correct format. I ran this code with a file I created that looked like: 123456 100 77 88 55.1 654321 88 77 66 55 I saved the file to C:\hw_5-1_ext1.txt and compiled the program and it ran fine. [quote="Your Program Output"] Student … | |
Re: [code] int main() { int AccountNumber, loop, loopEnd; double InputBalance, MinimumBlanace, FinalBalance, CheckTopLimit; char AccountType; bool validAccount = false; ofstream fout; ifstream fin; fin.open("bankdata.nf0"); fout.open("bankdataout.nf0"); while (validAccount == false) { cout << "Please enter the amount of accounts" << "that will be updated for this month." << endl; cin >> … | |
Re: Does moving your function prototypes help? [code] // Hw-4_Bhasin.cpp : Defines the entry point for the console application. #include "stdafx.h" #include<iostream> #include<string> #include<cmath> void rev_str(void); double Mean(const int Data[5][4], int, int); void frequency(const int Data[5][4], int, int); using namespace std; int main() { char option; cout<<"\n Please choose from the … | |
| |
Re: You didn't seed the random number generator, so you're getting the same result everytime. [code] srand(time(0)); // Initialize random number generator. [/code] Oh and on a side note, I love your code. It's very easy to follow. | |
Re: Here's a silly little illustration I drew just now: | |
Re: If it's the [B][I]instructions [/I][/B]you're having trouble with then allow me to assist you: You have to develop a decimal to binary function. The decimal number that will go into your function is the one which will be produced from using the given "binary to decimal" function. You have to … | |
Re: [code]while (answer=='Y'||'y');[/code] Is like saying "WHILE ANSWER IS 'Y' OR " "WHILE 'y'" <-- What's 'y'? Your while loop isn't terminating. I'm sure the myriad of if statements using this logic are failing too. Try this instead: [code] while(answer=='Y' || answer=='y') [/code] | |
Re: [code]scout *p; p = new scout; //allocate the memory for a new scout struct [/code] | |
Re: int main() to begin... more to follow... Does your compiler fuss at you for not having header files or anything? Ahh I see what the problem is.. the arch is stopping or getting too slow. Let me see if I can track it down. and the int main(void) still works … | |
Re: Here [a link](http://msdn.microsoft.com/en-us/library/aa384042) that gives a code example to: "create a task that is scheduled to execute Notepad on a weekly basis. The task contains a weekly trigger that specifies a start boundary, a weeks interval, and a day of the week for the task to start on. The task … | |
Re: [code][B]void[/B] BST<KeyType, DataType>::traverse(TraverseType traverseType, void (*visit)(DataType)) [/code] Also, what the above comment suggests, your function is declared as a void (which means it doesn't return anything) and you're attempting to stuff the information returned (nothing) into the variable result. Eliminate the result variable, or set traverse to a bool and … | |
Re: Did you declare a pointer without allocating memory? [code] type_of_var *p; p = new type_of_var; // allocate memory[/code] We're really completely in the dark without any code. | |
Re: 1! = 1 2! = 1 x 2 = 2 3! = 1 x 2 x 3 = 2! x 3 = 6 N! = 1 x 2 x 3 x .... (N-2) x (N-1) x N = (N-1)! x N Could this help? A guess: [code] int theFact = … | |
Re: whoa [code]ifstream inData; inData.open("Unknown.txt");[/code] Try pulling that out of the for loop | |
Re: [code] #include <iostream> int main() { [B] [COLOR="Red"]using namespace std;[/COLOR][/B] // out of place int exercise[5], i; [B][COLOR="Red"]cin >> exercise[0];[/COLOR][/B] // is only entering one value for (i = 0; i < 5; i++) { cout << exercise[i] << endl; } return 0; } [/code] [code] #include <iostream> [B][I]using namespace … | |
Re: [B]numbers[insertItem-1] = insertItem; [/B] Does this mean if you insert, oh i dont know, "6432", it goes into numbers[6431]??? If it does I'd look at it again, because I don't think that's what you WANT it to do | |
| |
Hi folks, my name is Blake. I live in Southern Louisiana and am currently a second year computer science student at the local university. I am flabbergasted from working on this current project and happened to find this website on a much needed break. Narue's signature is what caught my … | |
Re: Nevermind. Damn. Got to it in time. | |
Re: [code] Data superStruct; superStruct.name = thatLastNameIRead; superStruct.address = thatAddressIRead; int mySuperKey = thatKeyIRead; myBST.insert(thatKeyIRead, superStruct); [/code] What is the question? You don't need to do anything to the other two inputs, they're strings already, which is what the struct's values are. Parsing refers to breaking something into parts, in general. … | |
Re: [code] #include <motivation.h> #include <drive.h> #include <dignity.h> using namespace omg; int main() { string whatAreYouThinking = "foppishness"; int numOfPeopleWhoWillHelpYou = 0; string typicalResponseToThis = "rofl"; big_Surprise(whatAreYouThinking, numOfPeopleWhoWilHelpYou, typicalResponseToThis) = goDoYourOWNhomework; return 0; } [/code] | |
Re: That code yields: 3, 7 , 11, 15, 19, 23, 27, 31 ... I think you're on the right track though. I'm trying to figure this one out too. | |
Re: Yep you only need it once for the entire program. Then just call rand() % 52 wherever you need it. If you're going to be doing a bunch of random numbers at a time, its a good idea to have it wait a bit before generating the next number. | |
Re: [url]http://www.cplusplus.com/reference/clibrary/cstring/strcmp.html[/url] strcmp: Compares the C string str1 to the C string str2. This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminanting null-character is reached. | |
Re: [code=C++] template<class T> class snake; template<class T> struct node { T data; node *next; }; template<class T> class snake { // . . . private: node *start_ptr; // . . . }; [/code] | |
Re: If you've made your network private, you've got your network key plugged into your laptop I hope :X | |
Re: if (!Continue()) is the same as saying if (Continue() != true) is the same as saying if (not Y/y) | |
[code] void myClass<temp_Type>::myFunction(myClass<temp_Type>* &firstClass, myClass<temp_Type>* secondClass) { } [call] myFunction(*this, &secondClass); [/code] I think I am fundamentally challenged on the "this" qualifier. I want to pass a pointer to the current object(ie the object I am calling the function from), but am stuck trying to pass the "this". Are there … | |
Re: Follow this link and read up on ctime for MFC applications. Seems you just need to set up a time interval of some sort, (ie if the user twiddles thumbs for 30 seconds, just continue) [url]http://www.cplusplus.com/reference/clibrary/ctime/[/url] Also for developing small projects at home I find Bloodshed Dev++ to be very … | |
Re: Look at line 13 [code] stop = num;[/code] Now ask yourself, "self, whats stop?" "a [I]character[/I]." "self, whats num?" "an [I]integer[/I]." Whats probably going down is that the the char (stop) is being assigned an integer, which in effect is tossing your loop off. Are you only interested in positive … | |
Re: 62: ptr->item; what about it? 89. while(ptr->next !=NULL) figure out why in ptr->next never becomes null I'm betting on the problem being in your insert function. | |
Re: Item *tempItem = items[i]; cout << *tempItem; ???? | |
Re: [code=C++] mean3(value1, value2, value3); [/code] Whats happening here is that your returned value has nothing to come back to. In other words, the function is executing but then the returned value (mean) is flying off into fairy world. Do what Denniz said, just adding a "cout<<" to the front, or … | |
Re: She spoke more to idiot America, with a cheerful, emotionally charged, do-gooder attitude that people love. And its true that America votes for the best speakers, because psychologically we're stuck in a deferential society based on emotional response from debates and speeches. Like one of the previous posters said, Biden … |
The End.