What is Function in C Language part-2

WHAT IS FUNCTION ?


piece of code to accomplish certain operation.

It has a name for identification

There are two types


  predefined functions
  user defined function


EXAMPLE--


function in c,user defined function in c
example of function in c

Types of  functions in C 


Depending on whether a function is defined by the user or already included in C compilers, there are two types of functions in C programming.

There are two types of functions in C:


Standard library functions 
User defined functions

Standard library functions


The standard library functions are built-in functions in C programming to handle tasks such as mathematical computations. I/O processing, string handling etc.

These functions are defined in the header file. When you include the header file, these function are available for use. For example:

The printf() is standard library function to send formatted output to the screen (display output on the screen). This function is defined in "stdio.h" header file.

There are other numerous library functions defined under "stdio.h", such as scanf(), getch() etc.

User-defined functions


As mentioned earlier, C allow programmers to define functions. Such functions created by the user are called user-defined functions.

Depending upon the complexity and requirement of the program, you can create as many user-defined functions as you want.

Working of User-defined function --


#include <stdio.h>
void fun()
{
---------
---------
}
main()
{
----
----
fun();
----
---
}

The execution of  a C program begins from the main() function.

When the compiler encounters fun(); inside the main() function, control of the program jumps to 
'void fun()'.  And the compiler starts executing the codes inside the user-defined function.

The control of the program jumps to statement next to fun(); once all the codes inside the function definition are executed

Comments

Popular posts from this blog

Notepad, Wordpad and Paint

HOW TO PASS CCC EXAM WITH ONE ATTEMPT (NIELIT)

Inheritance in C++ Language(part 1)