Error related to Scanner in every program

For every code I write I am getting an error related to NosuchElementException during run time

Hi @tanjuljain19,
Please save the code on ide.codingblocks.com and share the url … i am unable to see your code right now.

Hi @tanjuljain19,
Your code will work fine but just remove the while loop with sc.hasnext() …There is no need of that loop. Other than that your code does not works for n=1/