Simple code structure and syntax

Hello,

I am programming a robot and I need it to do various 'things'.
There is a main loop (void loop) which it will run over and over - like usual.
but my question is, as I think it will simplify it and make it easier to write/understand, how I create small 'sub codes' that can be called upon?
Literally just the naming of a sequence and how to jump in between them.
For example-

Is obstacle >2m away? (CheckDistance)
//then goes to CheckDistance
IS incline >20Degrees? (CheckIncline)
// goes to CheckInline

CheckDistance:

Read (ultrasound sensor etc)
Write( Etc)

CheckIncline:
Int theta
atan(theta) -- // some function

thanks
harry

Breaking the program into functions is the way to go. See the planning and implementing a program tutorial.

The several things at a time tutorial may, also, have some good information.

Or do a search on state machines