As you know, C functions are basic building blocks in every C program. We have given key points those to be kept in mind for using existing C library functions and writing our own functions in a C program efficiently.
Key points to remember while writing functions in C language:
- All C programs contain main() function which is mandatory.
- main() function is the function from where every C program is started to execute.
- Name of the function is unique in a C program.
- C Functions can be invoked from anywhere within a C program.
- There can any number of functions be created in a program. There is no limit on this.
- There is no limit in calling C functions in a program.
- All functions are called in sequence manner specified in main() function.
- One function can be called within another function.
- C functions can be called with or without arguments/parameters. These arguments are nothing but inputs to the functions.
- C functions may or may not return values to calling functions. These values are nothing but output of the functions.
- When a function completes its task, program control is returned to the function from where it is called.
- There can be functions within functions.
- Before calling and defining a function, we have to declare function prototype in order to inform the compiler about the function name, function parameters and return value type.
- C function can return only one value to the calling function.
- When return data type of a function is “void”, then, it won’t return any values
- When return data type of a function is other than void such as “int, float, double”, it returns value to the calling function.
- main() program comes to an end when there is no functions or commands to execute.
- There are 2 types of functions in C. They are, 1. Library functions 2. User defined functions
There are many inbuilt C functions which are offered by C compiler. You can check list of all C functions and simple example programs with outputs below.
Ask your questions or clarify your/others doubts from,