We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Since -1 is not a valid being tested then why even include the statement: n < 0. Instead just use:
if(n > 9){
...
}else{
...
}
The problem above also has a logic error if n = 0 since it will print "Greater than 9" because x[n]= "Greater than 9"
I know it will pass the test cases; however, since "everyone" seems to be using this site to hire programmers then the code presented should be written for professional quality and not just to pass an inadequate test case set.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Conditional Statements
You are viewing a single comment's thread. Return to all comments →
Since -1 is not a valid being tested then why even include the statement: n < 0. Instead just use:
if(n > 9){ ... }else{ ... }
The problem above also has a logic error if n = 0 since it will print "Greater than 9" because x[n]= "Greater than 9"
I know it will pass the test cases; however, since "everyone" seems to be using this site to hire programmers then the code presented should be written for professional quality and not just to pass an inadequate test case set.