You are viewing a single comment's thread. Return to all comments →
A simple and perhaps readable solution.. You can use n instead of temp as it's dummy..
else if(n%5 >= 3)
Just a tip I've learned from my professors, you should rarely ever have to rewrite the same lines of code, see how your initial if and your default else are doing the same thing? You could condense this by doing this:
if(n>38 && n%5 > 3)
cout << n+(5-n%5) << endl;
cout << n << endl;
Makes it still readable, but in less lines of code. Also, in Industry code it's generally good practice to use curly braces on the body of if statements to prevent any confusion.
Will I get kicked out if I do this from nothing.