Post Page Advertisement [Top]

C-Programming

What is function in c-programming language?describe it easily.....

Home / c-programming /# What is function in c-programming language?describe it easily.....
What is function in c-programming language?describe it easily.....
  


Content:- 

  • introduction of function..
  • advantage of Function..
  • type of function..
  • library function..
  • user define function..
  • recursive function..

Introduction to Functions:-
As program grow in size and complexity it become more and more difficult to keep track of the logic; so program are divided into separate modules called functions, with each function reflecting a well understood activity, and of marriageable proportions..
vA function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions.
vYou can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division is such that each function performs a specific task.

vA function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.
Advantages of Functions:-
Functions separate the concept (what is done) from the implementation (how it is done).
Functions make programs easier to  understand.
Functions can be called several times in the same program, allowing the code to be reused.
there are two type of function..
a.libarary function.
b.userdefine function.
Library  Functions:-
  • the library  Functions are  common required functions grouped together and stored in files are called library. The library  Functions are present on disk with most of the compiler.
  • Library  Functions (e.g., abs, ceil, rand, sqrt, etc.) are usually grouped into specialized libraries (e.g., iostream, stdlib, math, etc.)
User-Defined Functions:-
The function defined by user is called user defined function.
A function is a block of code that performs a specific task.
All these functions are usually defined for local purpose with in the program.
C allows you to define functions according to your need. These functions are known as user-defined functions. For example
 // include statements
  // function prototypes
  // main() function
  // function definitions
there are three step that must be written when using any user defined function...
  • Function Prototype. 
  • Function calling.
  • Function Declarations
Recursive function:-
Recursive function are functions that call themselves,so,”A Recursive function is the invocation of computation inside a currently is executing identical computation therefor a recursive function is one which uses itself in its determination”.
the recursive procedure of computer science is free of a metaphysical component,and can be used to create elegant algorithm for problems that would be difficult to solve iteratively...



No comments:

Post a Comment

Bottom Ad [Post Page]