Basically in this session, we are taking about how we separate a program into different modules.
The main module is the one which we usually make as "int main" in C / C++, and there are many which are called "functions".
1. Function
In short programs, this would pretty much be useless. But, in long term and big-shot programs like applications, games, etc., this is so useful. A name of a function represents all of its "functions" which is already made in the initialization before we call the main module / int main.
Example:
int strlen(char s[100]){
int i = 0;
while(s[i]!=NULL){
i++;
}
return i; //this means the result value which will be returned after it is run by the function is i.
}
2. Recursion
Ever heard of loop and repetition right? This is just an implementation of loopings and repetitions inside a function, calling the function itself again and again until it fulfills some certain condition.
No comments:
Post a Comment