Well, it depends...
Lego NXT can be programmed using drag and drop of blocks for sensors and actions. Later on, you can program them usind C like languages.
The best thing is to find an example of some code that does almost what you want. If you study it and figure out how it works, you will be a long way towards being able to modify it to do exactly what you want. The problem is that while some people write well documented code that is easy to follow, others can be, well, cryptic...