2,712 Posted Topics
Re: Hint : [code] totals[die1 + die2]++; [/code] should be : [code] totals[roll] = die1 + die2; [/code] and make sure totals can hold up to 1000 dice roll information. | |
| |
Re: This is problematice : [code] int sum = 0; int x=0; // you declared it inside the for loop below for(int x=0; x<3; x++); { x=x+sum; //what happened to num array? cout << "The total is: "; cin >> x; } [/code] change to : [code] int sum = 0; … | |
Re: Can you insert the values the linkedlist contains into an array and then sort it ? | |
Re: hint : int x = 0, y = 0; int t = x + y; is not the same as int x, y; int t = x + y | |
Re: [QUOTE=new programer;1016597]Aha .. I got that .. what if I wanted the square to surround some writing .[/QUOTE] [code] cout<<"*******************\n"; cout<<"* Writing stuff *\n"; cout<<"*******************\n"; [/code] | |
Re: >>I'm storing base class pointers in a vector, the pointers are pointing to objects from the derived class ( Leads ). >>I'm unable to access the 'getter' functions of the derived class. How can this be done? It seems like you need the use of virtual functions. The error message … | |
Re: You shouldn't have to, as long as you initialize you variable upon deceleration. You can always do this if you like : [code] const int NOT_INITIALIZED_VALUE = 0; int i = NOT_INITIALIZED_VALUE ; //set to default value int j = 4; if(i == NOT_INITIALIZED_VALUE ) cout <<" i is not … | |
Re: Here is another one, but it delays process. [code] #include <iostream> #include <ctime> using namespace std; void delay(int milliSec){ const unsigned int clk_strt = clock(); while(clock() - clk_strt < milliSec) continue; } int main(){ for(int i = 0; i < 5; i++) { delay(1000); cout<< (i+1) << " seconds has … | |
Re: Problem : Write a C++ program that asks the user to enter 5 large values of n ( > 10), calculates their factorial using sterling’s formula and displays the results in a tabular format. Do what you can first : >>Write a C++ program that asks the user to enter … | |
Re: How to declare an array in c++ : [code] int Array[4] = {1,2,3,4}; const int SIZE = 6; float Array[SIZE] = {0}; //set all elements to 0 char Array[5] = {'1','2','3','4','\0'}; // "\0" is the null character and an array of char should end with it. int Array[]; // invalid … | |
Re: Your wording is a little ambiguous, how about an example? | |
Re: #include<iostream> #include<windows.h> [code] int main(){ string str = "hello"; cout<<str<<" "; Sleep(1000); //wait 1 second cout<<"world\n"; return 0; } [/code] | |
Re: Don't just dump your assignment and expect to get the source code to your problem, thats so ignorant. | |
Re: 1st) Read post 1, although if you PM, someone that knows a little math, he might help you. 2) [code] Let A = r+5(r-2)=28 Let B = 3(r+4)+5(r+2)=102 //Break down A A = r+5(r-2) = 28 = r + 5r - 10 = 28 //distributive rule = 6r - 10 … | |
Re: [QUOTE=VernonDozier;1023830]Garbage in, garbage out. Before you spend a lot of time analyzing your functions to see where the logic error is in calculating the lowest, highest, and average, loop through your array and make sure it's storing what you think it is.[/QUOTE] i.e the problem first occurs somewhere in here … | |
Re: Kind of, you will have to do an offset. [code] char convertNumericToLetter(int i) { if( i < 0 || i > 26 ) return 0; else return char('a' + i); } [/code] | |
Re: You are getting "close, but no cigar". Here is a hints : Try changing the prototype of : [code] void processScore(char& c);[/code] to [code] char processScore(int& numberGrade); [/code] It accepts a number such as 82, and should return a value associate with the number. You may use it like this … | |
Re: Maybe, try using code tags so we can see it better. | |
Re: Is it just me because I am seeing only 1 class diagram of the following : Person (attributes) person_name:string person_id:int (operations) getName(char) getID(int) In anyways, to create a class diagram, you have to think about what a class represents, and what it holds. What is your definition of a class, … | |
Re: >>Is there any way to stop the axis from rotating but allowing the object to translate or is there a trick to get around this. Yes, use push and pop matrix for that, as well as return the original coordinate back in place , see below : [code] //save current … | |
Re: >>Hi, from my understanding, if you initialize an object without the "new", it will be only saved in the stack. Correct, otherwise it would be saved in heap >>If the method exits, the object is destroyed. Is that correct? What about this code? Ok lets see, [code] int main() { … | |
Re: This should help : [code] string messageToYou(" try it out first"); string vowels("aeiouyw"); //whatever you think should be considered a vowel size_t upTo = vowels.size(); for int i = 0 to UpTo, increment i { if(message.find(vowels[i] != string::npos) //do something else //do something } [/code] | |
Re: what are you trying to do here : [code] int nuCoins = 50 - (number || randNo); [/code] Do you really mean that nuCoins will only be 49 or 50, provided that both contain some value ( which is your problem by the way, as pointed out ). | |
Re: First you need to understand the error , read [URL="http://en.wikipedia.org/wiki/Value_(computer_science)"]here[/URL] | |
Re: For 2d use gluOrtho2d(...); With 3d you will just have to adjust. | |
Re: Do you know what a global variable is ? Do you know what a local variable is ? If so then read on. Static variable is a mix between the two. Static variable has the same lifetime as global, while its scope could be contained like a local variable. Re-read … | |
Re: cough* look in code snippet section *cough,cough* | |
Re: [QUOTE=hiprakhar;1019344]Hi this is the code for life, universe and everything problem, where the program stops only when the user inputs the number "42" I tried to understand the problem, but could not make it that how the program stops at exactly 42. Any help would be extremely appreciated. [CODE]#include <iostream> … | |
Re: To answer you question you can do this : [code] int main() { int * largeInputArray = new int[1000000]; //use array here, ex, largeInputArray[0] = 12312; //after done using largeInputArray delete [] largeInputArray; return 0; } [/code] | |
Re: would this do ? [code] string words[3] = {"hello","olla","namesta"}; vector<string> vec(words,words+3); for(int i = 0; i < vec.size(); i++) cout<<words[i]<<endl; [/code] [edit] Oh, looks like someone already has gotten this answer [/edit] | |
Re: How about you let std do that for you? [URL="http://www.cplusplus.com/reference/algorithm/sort/"]Link[/URL] | |
Re: >>1. text pre-processor ( convert .doc to .txt) When you load in a doc file, you will also load in its formatting and other extra stuff. You need to weed that out. >>2. Sentence separator A sentence ends with a period(.), so use that as your end case with strings, … | |
Re: Not tested. [code] bool split_string(string& src, string& dst, char splitter) { //check for valid size or if splitter is in src if(src.size() == 0 || src.find(splitter) == string::npos) return false; int i = 0; while(src[i] != splitter) dst += src[i++]; return true; } [/code] | |
Re: >>i cant understand this code plz help me is iit right or not You tell me. Try it and report back. | |
Re: maybe you want : [code] HashTable<string> = new HashTable<string>(a, 100); [/code] [edit] Oh, you need to provide the template class and its definition in the same file. [/edit] | |
Re: This should get you started. [code] void printEvenAndOddSeperately(vector<int>& v) { for(int i = 0; i < v.size(); i++) { if( v[i] % 2 == 0) cout << v[i] << " is even\n"; else cout << v[i] << " is odd\n"; } } [/code] | |
Re: You need to put the definition and the declaration of a template class in the same file. | |
![]() | Re: I'll make it for you for a mere million dollar, what do you think? |
Re: Wrap everything around in a do while loop; [code] char quit = false; int guessNumber = 0; srand(time(0)); guessNumber = rand() % 100 + 1; do { PlayGame(); cout<< "quit <1 for yes or 0 for no > : "; cin >> quit; if( quit == false ) { guessNumber … | |
Re: [QUOTE=pman182001;1017994]I need help with IT210 week 7 programming problems 1 and 2 pseudocode can any one give some advice?[/QUOTE] Realize that we are not in the same class let alone the same school, most of us any ways, so we don't know what you are talking about. Imagine someone said … | |
Re: >>Why not (void*) FunctionType? or void* FunctionType? Otherwise it won't be a function pointer The above statement, (void*) FunctionType , or void* FunctionType? are the same. void (*pF) (); means that pf is a void pointer function. If the parenthesis wasn't there then it would be a regular function that … | |
Re: >> But Plus and Minus are predefined functions, like sin or cos, but how can i retun with sin+cos or sin+1? You will have to create a composite functions. [code] typedef float(*p_f)(float); //way 1 float composite(float arg){ return sin( cos( arg) ); } float composite2( float arg, p_f f1 = … | |
Re: This sounded interesting so I made a class that changes its type, simulates it at least. I know there are some bugs, but its getting late ( 3 am). Anyways, it could do the basic things a primitive datatype can to for now, that is add,subtract,multiply,divide. It can also be … | |
Re: Can you be more clear. Do you need to print numbers from 1 to 10 using do while loop? | |
Re: 1) This is not a code snippet, so why are you posting it as one. 2) cin >> extract only disregards white spaces so when the input is john kane, for your "c" variable, it only contains john. 3) Use [URL="http://www.cplusplus.com/reference/iostream/istream/getline/"]getline[/URL]. | |
Re: easy way : you can wrap another bool parameter. [code] double integrate( pointer_func Pf, int low, int high, bool flag, bool doFlag) { if( doFlag == true) { if( flag == true) { /* something */ } } else //blah blah } [/code] | |
Re: try posting your whole code | |
Re: suggestion : if you are a beginner, then forget about graphics stuff. You need to learn a language well before you can move on. suggestion : You might want to use Java. There are plenty of GUI that wraps java.awt among other things in java, where it lets you draw … |
The End.