2,712 Posted Topics

Member Avatar for EngneerNitemare

You can either use standard containers or use dynamic arrays. I will show you how to use both : using std::vectors [code] #include<iostream> #include<vectors> using namespace std; int main() { vector<int> Array; cout<<"Enter the array size : "; int Size = 0; cin >> Size; Array.resize(Size); //now populate for(int i …

Member Avatar for mrnutty
0
20K
Member Avatar for EngneerNitemare

1) Too much comment. 2) That is not how to call a function : [code] bubbleSort(int * Array, int SIZE); [/code] it should be [code]bubbleSort(Array,Size); [/code] 3) you bubble sort is wrong, j should start out as i+1 until the SIZE. 4) You aren't populating your array with random numbers, …

Member Avatar for mrnutty
0
170
Member Avatar for GSEninja

>>1) the style in which the user inputs their numbers for each 3x3 matrix should be - enter all 9 #s and then press enter... as opposed to enter a # press enter (9x) Ok, whats the problem with this? >>2) the only place i know where to put the …

Member Avatar for mrnutty
0
117
Member Avatar for DanieL34749

Recursion is a bad idea here. But if this is what you want : [code] String str = "vertical"; printVertical(str); [/code] and if the output should be : [code] v e r t i c a l [/code] Then your code shouldn't be hard. do something like this : [code] …

Member Avatar for mrnutty
0
70
Member Avatar for red999

[QUOTE=chaines51;1044571]To start off with, based on your example, I'm not sure you've got the general idea of inheritance. In general, you want to inherit from another class if the class you're building has all the attributes of the class you're inheriting from, plus some unique to this child class. If …

Member Avatar for mrnutty
0
110
Member Avatar for mebob
Member Avatar for abie

floats are made for spaced optimization, it does not necessarily have to be faster than double, especially in a 64bit CPU.

Member Avatar for mrnutty
0
173
Member Avatar for axed

You have a vector of int pointers that do not point to any memory. Try allocation memory first.

Member Avatar for mrnutty
0
111
Member Avatar for ayan2587

How about you warp your code into code tags, correctly. Then comment on each line of code, so we can see what you are thinking.

Member Avatar for ayan2587
0
125
Member Avatar for RaveFantasy

It would be better if you just let the overloaded operator work like this [code] MyClass A; //initialize A cout<< A[0].someGetFunc(); [/code] Do you know how to accomplish this?

Member Avatar for RaveFantasy
0
111
Member Avatar for fraandres
Member Avatar for jtddogg

First initialize your variables. Average = totalSum/totalElement. Thus totalSum should be computed first and then divide it by the array size.

Member Avatar for mrnutty
0
124
Member Avatar for college.guy
Member Avatar for mrnutty
0
109
Member Avatar for Ecanto
Member Avatar for confusedndazed

Input = cin x is a float y is a int r is a int for i to y means : [code] for(int i = 1; i < y; i++) { //code goes here } [/code] The "code goes here" part is result = result * i;

Member Avatar for confusedndazed
0
83
Member Avatar for orangejediman

Use an external library to handle musics and sound. I would suggest openAL (Google it).

Member Avatar for mrnutty
0
100
Member Avatar for Stivdion
Member Avatar for jmoran19
Member Avatar for mrnutty
0
126
Member Avatar for aarpitgenius
Member Avatar for samsons17
0
92
Member Avatar for uncbball

Why do you have 3 loops for a 1d vector? If you want to emulate it as a 2d then all you need is 2 for loops. [code] int A[4] = {1,2,3,4}; int B[4] = {1,2,3,4}; int R[4] = {0}; for(int i = 0; i < 4; i++) { for(int …

Member Avatar for abhi_elementx
0
155
Member Avatar for Afupi

You cannot use std::sort with list (if that is what you intended to do) list has its own sort. Here is an example : [URL="http://www.cplusplus.com/reference/stl/list/sort/"]http://www.cplusplus.com/reference/stl/list/sort/[/URL]

Member Avatar for Afupi
0
333
Member Avatar for pac-man

>>a problem arises whereby, when I access the vector from a different class, for some reason it "loses" it's contents and is empty? << From what content? How about you make a adapter class, that wraps vector, and make that adapter class singleton.

Member Avatar for pac-man
0
844
Member Avatar for jjf3rd77

Tell me if you see a problem here : [code] [COLOR="Red"]char an;[/COLOR] cout << "Please enter the operation you want" << endl; cout << "Press 1 for addition" << endl << "Press 2 for subtraction" << endl << "Press 3 for division" << endl << "Press 4 for multiplication" << …

Member Avatar for mrnutty
0
122
Member Avatar for Muathelbou

[URL="http://www.google.com/imgres?imgurl=http://www.cs.utk.edu/~pham/ascii_table.jpg&imgrefurl=http://www.cs.utk.edu/~pham/ascii.html&h=475&w=715&sz=142&tbnid=fHeK-W8VD8qXUM:&tbnh=93&tbnw=140&prev=/images%3Fq%3Dascii%2Btable&usg=__lHecv_bS2HSgp9GzbeNcEr00luM=&ei=MWD2StSzHsjT8QaPqsXzCQ&sa=X&oi=image_result&resnum=4&ct=image&ved=0CBEQ9QEwAw"]Ascii Table[/URL] They represent the value of a character. For example : All character from 'a' to 'z is represented by the decimal value 97 to 122. So a function that would check if a character is a lower case character might look something like this : [code] bool isLowerCase(char …

Member Avatar for tintin.iitk
0
227
Member Avatar for samsons17

Here is a hint : [code] ********** 10 stars ********* 9 stars ******** 8 stars ******* 7 stars ****** 6 stars ***** 5 stars **** 4 stars *** 3 stars ** 2 stars * 1 stars ** 2 stars *** 3 stars **** ***** ****** ******* ******** ********* ********** 10 …

Member Avatar for tkud
0
369
Member Avatar for samsons17

Well the top and the bottom are the same so you can just duplicate the top at the end, and the middle two are the same. I see no reason to use for loops for this.

Member Avatar for restrictment
-1
359
Member Avatar for COKEDUDE

>> Add a static method Account consolidate(Account acct1, Account acct2) to your Account class that creates a new account whose balance is the sum of the balances in acct1 and acct2 and closes acct1 and acct2. The new account should be returned. << Break this down : >>Add a static …

Member Avatar for skoiloth
0
209
Member Avatar for bushimports

You could use [URL="http://www.opengl.org/documentation/specs/glut/spec3/node76.html"]glutBitmapCharacter[/URL] Combined with function you can make this : [code] void renderBitmapString( float x, float y, float z, void *font, char *string) { char *c; glRasterPos3f(x, y,z); for (c=string; *c != '\0'; c++) { glutBitmapCharacter(font, *c); } } [/code] That is provided by lighthouse, [URL="http://www.lighthouse3d.com/opengl/glut/index.php?bmpfont"]Their link[/URL] Now …

Member Avatar for mrnutty
0
2K
Member Avatar for samsons17

You need to use the mod operator. example : [code] 2 % 2 = 0 4 % 2 = 0 12 % 2 = 0 114 % 2 = 0 [/code] as you can see even numbers mod 2 will equal 0. So use this as your test case in …

Member Avatar for Skeen
0
313
Member Avatar for jascase901
Member Avatar for sridhar123

[QUOTE=Ezzaral;1039359]++ Me too. Not only is it unnecessary, the code just reads a whole lot cleaner without them.[code]if (isComplete) {...[/code][/QUOTE] Yea, sometimes, but IMO not all the times. It depends on the variable name. When giving a variable name, if giving it isBlah doesn't necessarily make sense, for example, suppose …

Member Avatar for Ezzaral
0
238
Member Avatar for icu222much

I am a little doubtful about your code. Why does CarNode inherit from Car and it also composes it ? Note that in c++ objects is by default passed by value and Not passed by reference. You may wan't to read about pointers and reference in c++.

Member Avatar for VernonDozier
0
193
Member Avatar for Niner710
Member Avatar for mrnutty
0
113
Member Avatar for samsons17

Then you should take the input as a string. Then if the size of the string is greater than 1 then display an error message, else compare it with a or b. Doing this way you would have to use if/else. This isn't that bad if you don't have many …

Member Avatar for mrnutty
0
110
Member Avatar for violet101

>> I'm trying to eliminate the highest and lowest number out of 5 inputs then get the average of the remaining 3 inputs... In some instances, it gives me incorrect average.. << First find the highest/lowest integer. When getting input, make a variable that checks for high and low numbers. …

Member Avatar for violet101
0
188
Member Avatar for gretty

Let me try to explain further of the algorithm below : [code] An outline of the above algorithm would look something like: // positive integer I is given P = 1 //determines when a even factor of I is found while (I > 1) //I is you input number { …

Member Avatar for mrnutty
0
150
Member Avatar for PDB1982

Like super-sonic said, you need to pass your variables. This code : [code] double distance() { double center1, center2, point1, point2; double distance1, distance2, distance3; if (point1 >= center1 && point2 >= center2 ) distance1 = (point1 - center1); distance2 = (point2 - center2); distance3 = pow((distance1 + distance2), (1/2)); …

Member Avatar for PDB1982
0
135
Member Avatar for Towely

>> result = ((x % 10) + ((x / 10) % 10) + ((x / 100) % 10) + ((x / 1000) % 10) + ((x / 10000) % 10)); You know your formula won't handle number above 99999, try doing this with for loops or recursions.

Member Avatar for kri_prasad2000
0
185
Member Avatar for sgw

Maybe this will help : [code] int x = 0; cin >> x; //get input, expecting an numeric value if(! cin ) //check if input wasn't a numeric value { cin.clear(); //clear the stream while(cin.get() != '\n') //discard all bad inputs up until the line end ; cout<<"Bad\n"; //tell user …

Member Avatar for sgw
0
254
Member Avatar for LKH

1) Create a array, which represents a table. 2) use a for loop; [code] for(int i = 1; i != 5; i++) myArrayTable[i] = 6*i; //say, myArrayTable is already declared. [/code]

Member Avatar for eggmatters
-3
192
Member Avatar for skarocks47

First use code tags when posting code so we can read it better(its the button on the tool list that says "(code)" ). here is your code with code tags #include <iostream> using namespace std; int main(void) { int myweight; int myheight; int mynum; mynum = 703; int mybmi; int …

Member Avatar for jonsca
0
194
Member Avatar for xfreebornx

Use the suggestion above, although you might want to google sorting for knowledge experience. You can do this if you want to use std::sort; [code] # int main() { int x[5]; prompt(x); printreverse(x); std::sort(x,x+5); system("pause"); return 0; } [/code]

Member Avatar for mrnutty
0
115
Member Avatar for nalasimbha

First tell me how id has something to do with A[0].a I mean you have [code] if (id == 1) { A[0].a = 2; ... } else if(id == 2) { A[0].a = 1; ... } [/code] How does id correlates to A[0].a? What would A[0].a be if id is …

Member Avatar for VernonDozier
0
111
Member Avatar for sibobo

>> the problem is i dont know how to use the ifstream to read and use the code Morse that must be kept in .text file Then google it or something? Here is one from [URL="http://www.daniweb.com/forums/thread6542.html"]here[/URL]

Member Avatar for sibobo
0
165
Member Avatar for kat_stephens

You mean the input is something like this ? [code] <enter fraction > 123/452 [/code] And its read as a string. If so then separate the string into 2 components the left side before the '/' character and the right side, after the '/' character. Then use the [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/"]atoi[/URL]function .

Member Avatar for mrnutty
0
73
Member Avatar for punchinello
Member Avatar for freddyvf
Member Avatar for restrictment
Member Avatar for mrnutty
0
112
Member Avatar for alien2006.happy
Member Avatar for Rashakil Fol
0
290
Member Avatar for manoj.pg

>>If I have the class name in a string varibale, how can I instantiate an object of that class? Your question is not very clear, but my guess would be that you meant something like : [code] class Foo { public Foo() { } }; int main() { string className …

Member Avatar for mrnutty
0
683

The End.