181 Posted Topics

Member Avatar for ELBUF

So, you if else satements: [CODE] if (r<=3){ return 100; }else if (r<=6); return 80; else if (r<=9); return 60; else if (r<=12); return 40; else if (r<=15); return 20; else return 0; [/CODE] if you have more than one statement in any if/ if else statement, you must enclose …

Member Avatar for fadrior
0
658
Member Avatar for richman0829

[CODE] void initialize() { input.open ("WUexamp1.txt"); } [/CODE] Files should not be opened this way. You should pass the file name and the fstream object as reference. Like this: [CODE=c++] char fileName[] = "input.txt"; bool initialize(char[] fName, fstream& iFile) { iFile(fName, ios::input | ios::beg); if (iFile.fail()) return false; // Indicates …

Member Avatar for richman0829
0
289
Member Avatar for faaz

Ok, first off, please read this before posting code again: [url]http://www.daniweb.com/forums/misc-explaincode.html[/url] Second, you need to accumulate the numbers that are entered by the user. Depending on what you have learned so far, you can either use an accumulator (the numbers entered by the user are added to this variable with …

Member Avatar for dusktreader
0
2K
Member Avatar for sblass92

When you pass an array to a function, you only need to pass the name of the array (i.e starting address) Do not include size declarations [CODE=c++] pickColor(color[3][19], red, green, blue); // WRONG! pickColor(color, red, green, blue); // Correct [/CODE]

Member Avatar for sblass92
0
769
Member Avatar for alexa868

TBH, I cant read your code.... You used code tags but no indentation..... people are MUCH more likely to help if your formatting is good.... or even readable

Member Avatar for alexa868
0
96
Member Avatar for phpangel

[QUOTE=phpangel;1109970]well if u posted the answer and i ddnt understand does that means i'm nt C++ programmer, anyway if u ready 2 explain whatz the right answer then appreciate it.......if not thanx for ur advices and good bye[/QUOTE] Sorry to add to this already out of control fire BUT it …

Member Avatar for tux4life
0
958
Member Avatar for Izarian

Kind of a crazy idea but what if you write all of the ints/ doubles to a txt/ binary file then read them back in as chars?

Member Avatar for Salem
0
280
Member Avatar for XiaO yuEn

Your code looks like this: [CODE] for (int i = 0; i < sum_number; i++) { cout << "I cant read this code!!\n"; } [/CODE] Code should look like: [CODE=c++] for (int i = 0; i < sum_number; i++) { cout << "I can read this code!!\n"; } [/CODE] Oh …

Member Avatar for rohitn
-1
108
Member Avatar for blueman:-0

[QUOTE=blueman:-0;1112611]how i can do database in c++[/QUOTE] Ok, well first, I would read the rules on Posting in the forums because this is not a good question. This forum is for helping people out with the areas of C++ that they are having trouble with, your question is too broad. …

Member Avatar for Ancient Dragon
-1
55
Member Avatar for kriszy0515

[QUOTE=firstPerson;1112791]I'll give it to you for 1 zillion gazillion quintillion dollars?[/QUOTE] Ill do it for half that =) Im cheap heheh

Member Avatar for hag++
-3
74
Member Avatar for blueman:-0

Yea, looking at your code makes my brain hurt. A) Please read the forum rules on Code tags and.... B) You need to work on your style

Member Avatar for mrnutty
0
184
Member Avatar for Nexadus
Re: Lab

Just an idea.... im not sure if this is what you want but, you could create a struct that contains the chemical name and chemical makeup, then create an array of that struct to store file contents, which is easy. But in order to list in ascending order you HAVE …

Member Avatar for Nexadus
0
113
Member Avatar for sutty8303

[QUOTE=Intel;93471]Man you've done most of the work, just call your function in main, here is the code with some changes: [code] #include <iostream> #include <iomanip> const float PI= 3.14; float circle_area(float &radius); float circle_area(float &radius) { using namespace std; float area= PI*radius*radius; cout<< "The area of the circle with radius …

Member Avatar for peter_budo
0
306
Member Avatar for rkulp

[QUOTE=Salem;1109733]> (I loop it 250 times) ... > srand(unsigned(time(NULL))); Unless your code also takes 250 seconds to run, then srand() is always going to be seeded with the SAME value, and rand() is always going to return the SAME value(s) as a result. srand() needs to be called ONCE only, …

Member Avatar for hag++
0
247
Member Avatar for sfurlow2

I agree with jonsca, use a 2D array. The rest is all up to you and VERY customizable. Depending on how crazy your prof is.... you could step through the array and randomize each dice using rand() generator limited by the amount of letters in alphabet.

Member Avatar for sfurlow2
0
596
Member Avatar for gamerchick

You do need a second for loop (one for the rows, one for the columns, in the array) It may be easier to use pointers: [CODE] int* return_ptr(int str[][20], int x, int max_rows, int max_col) { int* a_ptr = new int; for (int i = 0; i < max_rows; i++) …

Member Avatar for dusktreader
0
230
Member Avatar for dlannetts

[QUOTE]combining tutorials never works for a newbie to C++[/QUOTE] Newbie to C++ trying to use WinAPI is going to result in a lot of headaches and errors. I agree with sticking to a console app.

Member Avatar for dlannetts
0
240
Member Avatar for said.amsur

Another good way of doing it (without use eof() ) is: [CODE] while (myFile.getline(line, '\n')) cout << line << endl; [/CODE]

Member Avatar for said.amsur
0
230
Member Avatar for zulqadar

[QUOTE=zulqadar;1107842]i am going to make the Database (i.e enter name, phone # etc) but how i will make it permanent (i.e to save it permanent). When i close the program and reopen, my previous Data that i had enter should Present??? How i will make it???[/QUOTE] [QUOTE=WaltP;1107846]Write to a file.[/QUOTE] …

Member Avatar for tkud
0
97
Member Avatar for keeperx

[QUOTE=keeperx;1108294]We first of all, I said im writing MY first c++ program, that does not mean that haven't been playing around with other code for a while. Secondly info about the mud can be found at lithmeria.com (still beta) and your sarcasm is unappreciated. Thirdly im not throwing around terms …

Member Avatar for keeperx
0
261
Member Avatar for rkulp

Also rkulp, please search the forums for already made topics that include your problem before posting a new instance of it. Click here: [url]http://www.daniweb.com/forums/thread253567.html[/url]

Member Avatar for rkulp
0
108
Member Avatar for nainish

Hey, welcome to the forums. Typically this forum is used for learning/ correcting purposes even on the more advanced stuff (which is in the 'Please read before posting' section of the forum rules) which means that forum members are not typically going to do the work for you. Instead, post …

Member Avatar for hag++
-2
142
Member Avatar for anthony5557

Check out this snippet you have: [CODE] //Get the user to enter a sentence cout<<" Please enter a sentence.\n"; cin>> Phrase; cout<<" The number of words in your phrase is " <<Phrase.length()<<".\n"; [/CODE] If you are ONLY looking for words, not the entire string length, then Phrase.length() won't work because …

Member Avatar for mrnutty
0
186
Member Avatar for Reborn121
Member Avatar for Nikhar

I dunno if you read this already but this is probably one of the better explanations ive seen [url]http://compprog.wordpress.com/2007/11/20/the-fractional-knapsack-problem/[/url]

Member Avatar for hag++
-2
63
Member Avatar for anthony5557

[CODE] char input[8]; cout<<"input: "; cin>>input; for(x=7;x!=0,x--) { cout<<input[x]; } [/CODE] The above will work but it is limited becauseyou don't really know how large of a string the user will enter. Instead use this: [CODE] const int MAX_STR = 20; // Obv can be any number char input[MAX_STR]; cout<<"input: …

Member Avatar for hag++
0
2K
Member Avatar for iou

[CODE] cin >> var1 >> var2 >> var3 >> var4; [/CODE] cin will ignore the whitespaces and newlines and input to multiple variables *EDIT: I noticed I didn't really offer a true solution because you dont know how many commands the user will enter so you could do this: [CODE] …

Member Avatar for mitrmkar
0
336
Member Avatar for chukka32

I agree with Dave, depending on what you've learned so far, accept all input as a string and use atoi and atof string functions to convert them (So your prog wont freak out if letters are entered into an int or double variable)

Member Avatar for chukka32
0
269
Member Avatar for C++ Beginner

Also, a smal logical problem : [CODE] int searchList(const int list[], int size, int value) { int index = 0, position = -1; bool found = false; while(index < size && !found) { if(list[index] == value) { found = true; position = index; } index++; } return position; } [/CODE] …

Member Avatar for hag++
0
2K
Member Avatar for Nautise

Looking at the for loop in your backwards function: [CODE]for(count = SIZE; count >= 0; count--); { cout << strPtr[count] << endl; }[/CODE] The first thing you print is strPtr[11] which will contain logical garbage, the array will only go to subscript [10] if the array size is 11. Instead, …

Member Avatar for Nautise
0
127
Member Avatar for atjfriday2

I dont know if Im totally blind (which is an option) but what problems are you having with the code. I was going to read through it and see if I could spot something but its easier if I know whats wrong.... guess I could also compile/ run it too …

Member Avatar for hag++
0
173

The End.