+ 1
Unwanted output
Hi, I had written a program which takes any year from user between 1- 3000 and print its century. Ex Input: 2045 Output: 21st Century But when I input 1000 it print: 11st century Here 11 is right but why 'st' is showing I had written in if statment than if it 11 than show 'th' Please help me https://code.sololearn.com/c7ovQ48ToX2e/?ref=app https://code.sololearn.com/c7ovQ48ToX2e/?ref=app
1 Respuesta
+ 2
its because you're passing 10 to post where you're getting the character 0 from 10 (charAt(1)) and incrementing it by 1 which results in 1, and your condition for 1 is to return st