Question: I want to generate random numbers manually. I know that every language have the rand or random function, but I'm curious to know how this is working.
Does anyone have code for that?

Answer: 
Have a look at the following:

[Random Number Generation](http://en.wikipedia.org/wiki/Random_number_generator)

[Linear Congruential Generator](http://en.wikipedia.org/wiki/Linear_congruential_generator) - a popular approach also used in Java 

[List of Random Number Generators](http://en.wikipedia.org/wiki/List_of_random_number_generators)

And here's another [link](http://www.javamex.com/tutorials/random_numbers/java_util_random_algorithm.shtml) which elaborates on the use of LCG in Java's Random class
If you are looking for a theoretical treatment on random numbers, probably you can have a look at Volume 2 of the *The art of computer programming*. It has a chapter dedicated to random numbers. See if it helps you out.