How to check for rational number?

How to check if a number is rational or not?
In other words, how to check whether the number can be written in p/q form?

Where do you get this number from?

as per my knowledge we are not able to give an irrational number as an input to computer.