Just looking for some judgement and/or advice on making it better.
I just started coding c++ like 3 days ago so I am moving on. I wrote a little more advanced script and I just wanted to know your guys judgement and advice on the code for a newbie coding it ;)
Code:
// Temperature convertor Created by JMC1987 |
A good habit is to use 'unsigned' instead of 'int' whenever possible. In case of this program it is possible.
It would make more sense fro end user point of view to use f/c instead of 1/2 as characters selecting input temperature type. It would be a good habit to use FP numbers instead of integer one in formulas whose end result is FP. |
Well there are 2 things I like to do (so may only be me):
1. Create and / or initialise variables at the start of functions / code eg. In main you create your float variables inside the if statements, but you do it twice. So start of main for me would look like: Code:
int main() a. You don't have to search throughout my code to find variable types as they are always located in the same place. b. Compared to yours, no need for useless second invocation of float creation. 2. I am a bit of a nazi when it comes to repetition of code. In your example this would be the replication of all the code in your if's. Your code: Code:
if ( temp == 1){ Code:
float tempin, tempout; |
Quote:
|
All times are GMT -5. The time now is 08:11 PM. |