WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look carefully at the parameters being passed to the print function. They are incorrect.

I guess I could be more explicit, but IMO the statement says it all. Check all the parameters. Do the calls and the function definitions match parameter by parameter?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Out with the Bad Blud, in with the good -- no wait, that's not right...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do you mean in the main function or in the print header function itself?

Rather than waiting 6 hours for a reply, just look at them all. It would have taken you 5 minutes. :icon_rolleyes:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That's pretty much it, except
1) main() is an int, so always use int main() .
2) Watch your formatting. Be consistent.
This section

while ( i <= num )                  // factorial 
     {
           result *= i ;
           i++ ;
           }
         
         cout << num << " ! = " << result ;
         cin.get () ;
}

should be

while ( i <= num )                  // factorial 
    {
         result *= i ;
         i++ ;
    }
         
    cout << num << " ! = " << result ;
    cin.get () ;
}

You are using SPACEs to indent -- excellent!! Switch to 4 though, not 5.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
void PartA();   // These are function prototypes,
void PartB();   // which is good and proper.
void PartC();
void PartD();
void PartE();
void PartF();
void PartG();
void PartH();


int main()
{

FileOut.open ("o:\\Answers2.txt");
	

void PartA();   // These also are function prototypes,
void PartB();   // not function calls
void PartC();   // Remove the void
void PartD();
void PartE();
void PartF();
void PartG();
void PartH();      
                                                                                                          
return 0;

}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look carefully at the parameters being passed to the print function. They are incorrect.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please work on your formatting. Your code is difficult to follow. This should help.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i have d same problem.

If you have the same problem, read this thread. It's marked solved so the solution has been found.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since your nodes don't store the parent, about the only thing you can do is read all the nodes and look for your current node in the children pointers.

IMO, you need to modify your node structure to add the parent node since you are traversing up the tree.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Peeps? :icon_rolleyes:

Try This and This

anirudh33 commented: the perfect answer +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You are making it hard on yourself. The board should be 4x4 because those are the playing positions. On output you should add the borders. That would alleviate all the checking to see if you are going to trash a border or not.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Use an array that holds all the IDs in use.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@Narue: I've never written a change making program. I didn't find any reference of that in my textbook. What should I look under?

It doesn't matter. If you've written a change program, you can use the concepts you learned. Since you haven't, you have to do this program without that background knowledge.

It's simply, if you enter 743, what's the largest Roman numeral that fits into this number. M doesn't. D does. Store the D and subtract the value leaving 243.

Now what's the largest? C, giving you DC and leaving 143. Continue until you have 0.

Once you get that done, add the functionality that instead of a simple CCCC you save the normal value CD instead. This is hard part.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Give your variables useful names. var1 could be gallons of milk for all we know.
2) What does the input file actually look like?
3) Maybe whatever value it outputs is exactly what's in the file.
4) Since you have no error checking, maybe the file can't be found, file is locked, etc, when you tried to open it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OPEN a file
WRITE or PRINT the data
CLOSE the file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Depends on what "red line" means. We can't even hazzard a guess without more information. Like maybe an error message.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Cool, yeah thats my problem... how would i do that? what would i google?

Umm,

You need to read the input as a string and after you've verified that digits were entered convert the string into an integer.

In other words

1) You need to read the input as a string - you better not say you don't know how...

2) after you've verified that digits were entered - loops and IFs

3) convert the string into an integer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hey everyone :) Hope you can help

Here is what I've done with the instructions given:

I need to know the average price difference between the cash and credit prices. But i'm pretty sure that only comes in at the end. Here is what my this function is supposed to do:
determine the difference between the cash price and credit price for an item and add this difference to the total of the differences. So what I've done below seems pretty basic to me- but I'm guessing this must be the error based on what I try to do with the code later on.]

Yes it seems pretty basic.
I suppose it could be the error, if we had a clue what the error is. Without explanation of any kind, I can see either no error, or a possible error. But I'm only guessing.

When asking for help, assume we know nothing about your code, and your thoughts on the program. You need to explain in detail what you are trying to accomplish, and what leads you to believe there's an error.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hello,
I just joined this web site and i'm new to programming and i'm stuck on this program, can't seem to finish it, after couple of days of trying to figure this program out, i realize i need help.
The program is pretty much done i just don't know where to put the default for player one. I have it for player two, but not for one. Greatly appreciated if someone could help.
Thank you.

defualt generally goes within the switch for player 1. Please be more explicit if that doesn't help. Remember, you understand the program and what you want to do, we don't unless you explain fully what the problem is.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i forgot to put DO in my program. since i was instructed to use DO-WHILE LOOP. i still have the same output if i use this code. But better to have the DO inserted.

Yes, you forgot to use DO. How you can forget DO when the assignment calls for it I'm not sure, but there you go.

So convert your loops into DO loops. Look them up in your book.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If I have .txt file include 10 digits such as
0//start bit
1
1
0
0
0
0
1
0//parity bit
1//end bit

If I put those into an array, how to check the first bit, the last bit and parity bit?

When you've read the data into your array, what's the index of the first bit, the last bit, and the parity bit?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

my goal is to ignore all spaces and just save the int, but the first digit is always iterated. THanks again.

Huh? That statement makes no sense. Use words you understand, not new ones you're not sure of [iterated?]. Digits are not iterated.

I think I figured out what you meant to say. The first digit is thrown away. Right?

Lets assume you entered " ..123..543 (. is SPACE)

printf ("Enter an arithmetic query in this format: [INT] [OPERAND] [INT]\n");

		while (((ch = getchar()) == ' ') && (ch != '\n')) {
				blank++;

This loop reads:
SPACE
SPACE
1

The 1 is not a SPACE so the loop exits.

while (((ch = getchar()) != ' ') && (ch != '\n')) {
				if (my_isDigit(ch)) {
					first = first * 10 + (ch - '0');
				}
			}

This loop reads
2, calculates first as 2 (hopefully first is set to 0 somewhere.
3, calculates first as 23
SPACE, not a digit, the loop exits.
You can figure out the rest.

Now this is something you could have figured out simply by sitting at your desk with pencil and paper and running through the code yourself. It's so much faster to desk-check your own work.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

okay, I took that advice,

Mine? Or thekashyap's?

You've got the isdigit() part right. What functions will convert a string into an integer?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

CAN use a bit of common sense.

Yes you may. And common sense dictates you don't lie if you want people to trust you.

To i have ro be exact in everything, about the statistics how do we know the actual one?

Research. I did, and posted a link that shows it. Therefore, I can be trusted.

Someone will always have different opinion about the statistics, i can post 50% true the next time some other posters will disagree and say 51% true

Opinions about statistics are worthless when the true statistical values can be proven. So keep your opinions to yourself and try GOOGLE to get facts. Then post the facts instead.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't see any char variables, so I presume you're trying to read a char into line 19, which asks for an int?

No, he wants to read an int but a non-int does it's looping thing.

You need to read the input as a string and after you've verified that digits were entered convert the string into an integer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You don't even want to try so you want us to program it for you? That's what you're saying, right?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

hi..
i am using windows 7 (32 bit) ultimate.

where can i get turbo c++ for windows 7??

what should i use for compiling and running c/c++ programming in windows 7

How about a compiler from 2010 instead of 1980's

If you have Windows 7 Ultimate, why do you want to use Turbo C Old and Decrepit? Isn't that like buying a Corvette and using a squirrel and rubber band for an engine?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

>> CAn we trust wikipedia ?

No.

Can we trust the Encyclopedia Britannica?
http://news.cnet.com/Study-Wikipedia-as-accurate-as-Britannica/2100-1038_3-5997332.html

At least with Wikipedia, errors can be/are corrected quickly -- much faster than EB can manage.

Since wikepedia half the stories are half true half false what is the point of setting up it the first place?

Prove your statistic... I don't believe it at all.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

well this is how my class thought me to do it, its called external variables they said ,

it is just like defining constants in a header file and the extern keyword tells the compiler that that variable is external and not to confuse with other "PI" variables from other namespaces ect...

I believe you misunderstood your class. And if not, you need an instructor that knows the language because your understanding is not correct.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And I'm a little new with programming so my formatting might be horrible, and I apoligize.

Easily fixed with the link provided above.

My program is suppose to go through and look at any infix notation equation and print out a reverse polish notation equation. I have my program do this, but when I use the cout command to try and print out the new equation, it shows a blank line, and ends the program. I need it to actually print out the RPN equation. If you need anymore explaination let me know, and I will try to add more detail.

Then your RPN must not be created properly. Output values at key places in your program to make sure the values are as you expect. What values are being pushed, popped, tested, and so on? If they aren't correct, you need to figure out where it goes wrong. Add more cout 's

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First you need to fix many things you are doing completely wrong.
1) fflush(stdin) is an error -- follow the link
2) Never NEVER call main() . main() is not a recursive function. Create a loop instead.
3) The syntax

void error (int), add (int, int, bool, bool),  
	 subtract (int, int, bool, bool), 
	 multiply (int, int, bool, bool), 
	 mod (int, int, bool, bool), 
	 divide (int, int, bool, bool);

is quite confusing. Each should have its own definition and its own line.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm supposed to make a program using getchar() to input the operation entered, then return the result of the operation after extracting the operands and the operator and calculating the result.

I was thinking of using functions like isdigit() or ispunct() to extract the operands and operator

That seems to be a reasonable direction to head. Head that way and see how far you can get.

By the way, leave the computer alone until:
1) You write an equation on paper (15+30=45)
2) You look at and process the equation character by character on paper. In other words
What do you do with the 1
What do you do with the 5
etc.
3) You write down your process step by step
4) The process gives you a correct solution.

Then you have the information to start coding the process and it will go very easy.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Where do you deal with the highest value? I only see lowest.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It shouldn't have.

Problem #1) Never define a variable in a header file. The statement float PI = 3.146; should only be made in a source file. If you add the header to 4 source files, you will have 4 definitions of PI causing lots of errors.

Problem #2) The extern statement goes in the header file so other sources that include the .h file know that PI will be defined in another source.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Formatting - your code is too hard to follow without proper formatting
2) Based on the problem as stated - "I can't get it to print out the new equation" - use cout . If that's not helpful, try explaining the problem. Don't make us guess.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Maybe you should read this Code Snippet then, as well as the posts.
Follow the code using pencil and paper to understand code in general.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

A DOC file isn't text, it's binary. The only way to do what you want is to understand the format of a .DOC file. Use GOOGLE.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

THINK about it. What does ins.get(ch); do? What do you do with each value they get?

Follow your code with pencil and paper and figure out what it's really doing. That way you won't need to waste 6 hours hoping we'll fix it for you. In 10 minutes you'll get your answer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

IRC is a chat room with you can chat with other online posters. No point going there since there are around 5 regular people there

And how do we get more people on IRC if you don't want anyone to go there? Make up your mind!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Login info must be stored in Database, to enable multiple user with their individual password.

Or a text file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your analysis is perfect for a professional setting. But for an instructional setting, in order to understand all aspects of programming, you must learn how to do certain things that would not be good in a professional setting. Like writing your own strcmp() function, or testing whether a stack is full or not.

So Dude, brush up on what is needed in a school, not your job. Instructors do not teach all aspects of coding C++ immediately. It takes time. When you start learning stacks, queues, etc., chances are exceptions are still far in the future. And judging from the OP's post, he's not that far along or the question would not have stumped him. That's why the answer did, too. He's new.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How many ins.get(ch); statements do you have in your loop? Why?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Think about it...

How do you add 2, then 3 to get the values you want?

x = x + 2;
x = x + 3;

Where would you add 2, then 3 in your program?

Don't you have a FOR Loop in your program? What does it do?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

that my code, im having trouble with the counting letters and words part, any suggestions??

Sure. Explain why you think it's not counting words and letters.

also im not even getting an output, but thats probably sometihng minor with the last function?

You're calling the output function. What makes you think it's not giving any output?


When asking for help, it's important to also give the details explaining what is (or isn't) happening. Not just "Broke, why?"

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Stuck on a program i've been trying to work on for the last few hours.

A user enters 2 arrays, both are charater arrays with 5 spaces each.
They are passed into a function that compares the 2 arrays to each other character by character. If they are idenital the user is informed of this.

void comp(char string1[], char string2[])
{
	int i;
	for(i = 0; i < 5; i++)
	{
		if(string1[i] == string2[i])
		{
			printf("they are the same.\n");
		}
		else
		{	
			printf("they are not the same.\n");
		}
	}
}

This is what i have so far but from my googling it seems like you can't use "==" operators to compare to character array spaces.
Anyways around this or am i missing something obvious?

Yes. An explanation of your problem with the code. As I see it, the loop and IF are OK, although the contents of the IF probably will cause a problem.

Run through your code with pencil and paper. What happens?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

"with user responsibility" == "bad design"

Disagree -- based on the definition of the problem. User does not mean the person running the program. User means the programmer, and it is a very appropriate way to teach techniques.

The third solution is to throw exceptions if the stack is full (or popped empty), but, depending on the style/constraints already adopted by your project, it might be appropriate or not.

This is not a solution because throwing an exception by definition is a failure. The question, as I read it, is to prevent a failure.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How do you add 2, then 3 to get the values you want? Where would you add 2, then 3 in your program?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you wish to use his solution, ask him. Otherwise, you
1) call the isFull() function.
2) if the stack is not full, return FALSE.
3) if the stack is full, return TRUE.
How you test for full is up to you since you design the stack itself.

There is no need for an assertion.