Header Ads Widget

Ticker

6/recent/ticker-posts

Function in c.

 What is function :-

                                   Function is a group of statement or instructions  that are written with a purpose to perform a certain task whenever it is require.

 Their are two type of  function use in c programming-

1)Built-in function

2) user defined function

1)Built-in function:- 

        built-in function in c are provided with c -package and the definition of there function are already define and stored in c-library. The declaration of these building functions are given in header (.h) files.

Ex. -:  printrf() - To print something on standard I/O.
          scanf() - To read something from standard I/O.
         pow() -  To calculate the power of a number.
         strcat()- To concatenate two strings.
        etc.

2)User define function:-

     These function are defined by the programmer for specific purpose to used in his program.

Example:-  If you want to make a function 'sum' for adding two numbers then the syntax of this function is :-

int sum(int x , int y)
{
    int z;
    z=x+y;
    return z;
}

Advantage of using function :-

(i) Modular programming :-

                  It is a programming paradigm that breaks down the bigger problem into smaller subproblem. these subproblem are solved separately  and their solution are combined to solve the bigger problem.

(ii) Easier to write and understandable the program.
(iii)Fault detection and isolation is easy.
(iv) Debugging and maintenance is easier.
(v)Facilitates reuse ability of codes.  

<<Pre--Practice question on loop                                      Next--Function declaration>>


Recommended Post:

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-


            

Post a Comment

0 Comments