Computer Science Canada Percentage Calculating program |
Author: | Mr. Gruntsworthy [ Thu Nov 30, 2006 11:18 am ] |
Post subject: | Percentage Calculating program |
This is a little program i wrote to test my knowledge in C++ so far. It's a little nifty program, but it was made with what i've learned and is by no means the way it should be written. But here it is, in a .zip format, complete with all source code files and the Debug folder with the executable program. Take a look at the source code and let me know what you think. |
Author: | wtd [ Thu Nov 30, 2006 12:37 pm ] | ||||||||||||||||||
Post subject: | |||||||||||||||||||
This should be in C++ Submissions, so if a mod could move it, that would be great. That said, here's all we need to see:
Now, this kind of comment is useless:
You have declared "anyKey" near the top of your program, yet you don't use it until the bottom. This is puzzling since most of your variable declarations have been pretty much done just when they need to be.
Perhaps this should be:
That would negate the need for the comment. For the following:
How about?
At the end of each branch of your conditional you read into the anyKey variable to affect a pause. Since this will happen either way, it does not belong in the conditional.
The above can be written more clearly with a knowledge of operator precendence levels.
Also with regards to that. You do not need to separately declare and initialize a variable.
According to the C++ standard, any main function which does not explicitly return an integer returns zero. Your "return 0;" is okay, but unnecessary. Oh, and the contents of your conditional should be indented. |
Author: | Mr. Gruntsworthy [ Thu Nov 30, 2006 4:02 pm ] |
Post subject: | |
It seems to me that you are an experienced programmer, and I thank you for your very informative critisizm (not being sarcastic). This is my first feature length written program, using the small portion of C++ ive learned. I knew it wouldn't be perfect, but I had less critisizm about it than I was expecting. Next time i write a program, I'll take your info to heart and try to get it to be a little more organized. But other than that, what do you think of this program? Useful, or useless |
Author: | wassonator [ Fri Jun 26, 2009 6:48 pm ] |
Post subject: | Re: Percentage Calculating program |
man their are such things as fractions with denominators that are larger than their corresponding numerators "//Purp: A complex program that gives you the percent equivalent "...............................hardly // of a fraction. |