Get rid of the "SEE YOU LATER" at the end. (Why do beginners always do that?)
For some reason, I like stuff like that.Do not put copyright notices in simple code like this (or anything you write for the next four years).
It's never too early to start claiming your code. People steal beginners' code all the time. For example, one of my earliest programs was:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello world!" << endl;
return 0;
}
I've seen this program (verbatim) hundreds of times since I wrote it, so I can only assume that people have stolen my code, and I have not received a penny in royalties from it. If I had copyrighted it, I'd be a rich man now.
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
I think you should also do some form of syntax checking ...
Check what happens if you input 56 + 5 ? (with very much spaces between '56' and '+' ... And with very much spaces between '+' and '5') ...
You could make a function which reads out all the spaces (and characters between the operand and the operandus)
Or, you could just give an error ...
You have to decide it !
BTW, Nice program ! :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Include a space between #include and <iostream>
The space isn't really needed, the code will also compile without a space between #include and <iostream>
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
It was a suggestion for readability. It's minor but the space should be there as far as I'm considered. But it's just my opinion.
Actually it doesn't make much sense as it's his choice to write it with or without a space :) ...
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Of course it is but when given a choice people often make a bad one ;)
I'm not trying to make a big stand on this but I would say this is one of those things that just make sense to do and I thought I would encourage it.
In this case he can't make a bad choice ...
And here stops the discussion !
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
You should not put any spaces
between the arithmetic expression, it should
be written as 5+3 or -6+3, and so on
Yeah, agreed, but you're expecting the user is always inputting valid information, without ever making a typo, so it might be better to do some input validation and display an error in that case ...
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
I disagree.
Why it's just a useless discussion, and what's the main topic?
"a space" ...
BTW, What wrong choice could he make in this case ?
NO ONE !
Because the C++ preprocessor is just ignoring that space ...
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243