Forum: C++ Aug 23rd, 2009 |
| Replies: 7 Views: 379 Did you initialize option? you seem to be commenting //system("pause");.Are you really using a standard compiler?
>>The problem seems to be if I input strings or characters, it crashes
First... |
Forum: C++ Aug 17th, 2009 |
| Replies: 9 Views: 686 True.
But the program still wouldn't work
This line
int small, temp;
small (its the index)is Ok but temp stores the value of the element in the double[] input_array, so you will always... |
Forum: C++ Aug 17th, 2009 |
| Replies: 8 Views: 908 Binary Search would come into picture only iff you have a sorted input like dell, bell etc and corresponding sorted array to search for. Your examples don't have a sorted string in most of the... |
Forum: C++ Aug 15th, 2009 |
| Replies: 13 Views: 656 I didn't want to poke but firstPerson's method doesn't take into account the frequency of characters, so for inputs
like s1 = roorsseett
s2 = sosretetet
returns true.
letter s1 ... |
Forum: C++ Aug 14th, 2009 |
| Replies: 14 Views: 447 You haven't said anything about the desired output of your program, the total you were expecting, what testsdid you do , if you ae using compound interest, then the formula looks wrong to me.
... |
Forum: C++ Aug 14th, 2009 |
| Replies: 9 Views: 501 I doubt whether this will help..:S , your read_in file remains intact, your read_out now is:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word;
//... |
Forum: C++ Aug 12th, 2009 |
| Replies: 6 Views: 325 double interest = .00575;
I think the monthly interest is given.
double monthlyInterest = interest * 12;
is actually the yearlyInterest which comes to ~ 7 %.
Well, if you are calculating... |
Forum: C++ Jul 20th, 2009 |
| Replies: 10 Views: 545 Then..
I wouldn't agree.
A snippet which might help you if you can see the link.:twisted:
#include<iostream>
#include<string> |
Forum: C++ Jul 19th, 2009 |
| Replies: 10 Views: 545 Another approach could be
1.Make another userGuess string.
2. First , fill all the characters in userGuess string
with underscores( _ ).
3.Make changes in the userGuess string.
guess();... |
Forum: C++ Jul 18th, 2009 |
| Replies: 11 Views: 867 //Get lowest
lowest = scores[0];
//Without the for loop code works fine.
//for ( int count = 1; count < numScores; count++)
//{
//if(scores[numScores] < lowest)
// Out of bounds
//array... |
Forum: C++ Jun 30th, 2009 |
| Replies: 18 Views: 769 cin would stop reading as soon as it encounters a space !
Use getline instead:
getline (cin , passage)
Instead , |
Forum: C++ Mar 30th, 2009 |
| Replies: 10 Views: 516 Yes you need to else you work with garbage values.
May be you didn't quite get it,by using an ampersand you actually give the function true memory addresses of
initial, fuel, taxRate
to... |
Forum: C++ Mar 30th, 2009 |
| Replies: 10 Views: 516 void displayInstructions (float &initial, float &fuel, float &taxRate)
//there is an ampersand
{
cout << "The following program will display 3 homes." << endl;
cout <<... |
Forum: C++ Mar 30th, 2009 |
| Replies: 10 Views: 516 Because you did not initialize your variables
Suppose you change
void displayInstructions ()
as
void displayInstructions (float &initial, float &fuel, float &taxRate)
//and delete this... |
Forum: C++ Mar 30th, 2009 |
| Replies: 10 Views: 516 I think in the function
void displayInstructions ()
//You should be passing
//these parameters by reference
//float initial, fuel, taxRate;
//since you seem to use those values in
//... |
Forum: C++ Mar 30th, 2009 |
| Replies: 4 Views: 669 that is because int the function
void printForm(char form[][6], int row, char column)
you get into the block only once
if(i == row - 1 && j == static_cast<int>(column)-65)
You don't make... |
Forum: C++ Mar 4th, 2009 |
| Replies: 18 Views: 692 This would certainly work if all the numbers are distinct,else you 'll get only the last occurrence of that number in the 'loc' |
Forum: C++ Feb 23rd, 2009 |
| Replies: 10 Views: 937 |
Forum: C++ Feb 22nd, 2009 |
| Replies: 7 Views: 1,122 Suppose,instead of using
cin.getline(...)//the failbit is set if input
//exceeds max numbercharacters allocated
you manually accept each letter,you can always count the number of characters... |
Forum: C++ Feb 21st, 2009 |
| Replies: 4 Views: 837 First,for a a number in an array call it as
int num;
//Your expression for evaluating control variable
//certainly doesn't give all the factors,referring to
//for (int j = 2; j <= floor... |
Forum: C++ Feb 21st, 2009 |
| Replies: 7 Views: 1,122 You were displaying all the letters
for (loopCount= 0;loopCount < numLetters;loopCount++)
{ //to display CAPITAL letters
//You enter inside if block only if it is a small letter.
//else... |
Forum: C++ Feb 8th, 2009 |
| Replies: 6 Views: 740 You almost got it right .
char name[5][50];
for(int i=0;i<5;i++)
{
cin.getline(name[i], 50);
}
for(int i=0;i<5;i++)
{
//or cout<<name[i]<<"\n"; |
Forum: C++ Feb 6th, 2009 |
| Replies: 5 Views: 606 Since you are just finding the prime factors of a number,how about something like this::
//fragment code where num is your real number
if(num>0)
{
for(int i=1;i<=num;++i)
{
... |
Forum: C++ Jan 21st, 2009 |
| Replies: 16 Views: 3,668 or
ifstream myfile(file.c_str()); |
Forum: C++ Jan 21st, 2009 |
| Replies: 16 Views: 3,668 As far as the errors you are encountering,
should be replaced with:
ifstream myfile;
myfile.open(file.c_str()); |
Forum: C++ Jan 18th, 2009 |
| Replies: 3 Views: 274 Should be something like this::
#include<iostream>//Watch out
using namespace std;
class first
{
public: //Added
int reverse()
{ |
Forum: C++ Jan 17th, 2009 |
| Replies: 6 Views: 283 Add the line
using namespace std;
after
#include<iostream>
or,use std::cout<<"Test"; |
Forum: C++ Jan 16th, 2009 |
| Replies: 16 Views: 3,668 That's done Murtan suggested a better way to solve the problem,I got your point and may be we utilize the memory a bit more efficiently this time in our while loop..
//fragment code
while... |
Forum: C++ Jan 16th, 2009 |
| Replies: 5 Views: 1,037 I believe that by placing a break statement you were trying to return back to the main() function.
Placing a
return;//Instead of break might be what you are looking for
The above... |
Forum: C++ Jan 16th, 2009 |
| Replies: 16 Views: 3,668 string line;
char str[BUFSIZ];
1. Murtan is absolutely right when he says that declaration of
str[BUFSIZ];
int array_words[10];
should be before the loop where the content of 'str' is... |
Forum: C++ Jan 15th, 2009 |
| Replies: 16 Views: 3,668 If you want the whole line to be printed ,then replace every call with..
pch=strtok(str,"\n");
I don't understand,when you say
If you want to store each word in your file(if that's what... |
Forum: C++ Jan 14th, 2009 |
| Replies: 16 Views: 3,668 Though ,not a good approach but the following approach does work.(if your input contains texts which are separated by more than a couple of newlines,expect some unexpected characters in the output)
... |
Forum: C++ Jan 13th, 2009 |
| Replies: 9 Views: 496 Refer http://www.daniweb.com/tutorials/tutorial71858.html |
Forum: C++ Jan 13th, 2009 |
| Replies: 9 Views: 496 Ok,this is the else part of your loop
When you use a cin statement ,the cin stops reading the buffer after it encounters a white space or a newline.So when you read something like this:
"Civics... |
Forum: C++ Jan 10th, 2009 |
| Replies: 6 Views: 356 You say that you don't know the exact number of digits.
Then why not he input to the function be a string
such that
string convertNum(string num)
{
//1.set counter to 0
//2.Check if it is... |