How can I define a function or write a command in such a way that the input or argument of the function or command is the result/ouput of the previous lines in the same notebook? In fact I need a sort of inter-connected notebook, i.e. if the first function changes, all subsequent functions change automatically.
This is one of the roles of Dynamic functionality in Mathematica. So perhaps read up on these capabilities of Mathematica and experiment with them for the sorts of notebooks you are wishing to create.