You are viewing a single comment's thread. Return to all comments →
To account for a special case like 1, you one can leverage the ternary operator to assign value to sum like so:
int sum = (n==1) ? 1 : n+1;
This will mitigate logic errors in code later on.
Seems like cookies are disabled on this browser, please enable them to open this website
Day 19: Interfaces
You are viewing a single comment's thread. Return to all comments →
To account for a special case like 1, you one can leverage the ternary operator to assign value to sum like so:
This will mitigate logic errors in code later on.