- In the next few sections we
will talk about user defined functions.
We have used functions so far in many, many
examples throughout this course.
However now it's a good time to reflect
and think about some of the specifics
involved in user defined functions.
Let's recap what is a function.
It's simply a group of statement
that perform a specific task.
Now that you have some experience writing statements in C,
and planning and implementing shorter or longer programs
let's focus on what that task is.
Before writing your code have you
clearly identified the purpose and scope?
Do you know what this program is about to do?
What is the intent?
And what was the main criteria that led you
to define certain functions?
Each task is defined to implement
the step towards providing a solution to a bigger problem.
You can not define a program that
solves one problem in it's entirety.
You have to chop the problem into smaller components
and tackle each one of those individually.
Let's see in an example of a C program
what does it mean?
This code is not producing any output.
In fact it's just a skeleton.
It's a great way to explain the concept
of dividing the task into smaller tasks.
Just look at this Line 16 through 23.
Even without knowing what the problem is,
or what's the purpose of this code is
you read, read data, validate data,
process data, analyze results, generate report,
write formatted report, archive data, disseminate results.
Regardless of what the problem at hand is
it is always possible to break it down
along those lines.
This is not a recipe, it's not a concrete example.
It's a generic approach to solving problem.
We scroll further down to function definition.
We see how the skeleton is ready for us
to simply pour in the content.
If you think like this you are more likely
to come up with solutions that make sense,
solutions that can be better maintained in terms
of code readability, code usability, debugging, and so on.
Over the next several video segments
we will discuss even more details
about entire approach to user defined funtions
so that they are the best they can be
in terms of efficiency, readability,
reusablity and so on.