About Me

Hey friends! My name is yuvraj basnet. I'm going to introduce myself.I have born and grown up in india(chandigarh) and I'm studying second year of B.C.A computer science field. My father serving in indian air force. My mother has been taking care of house hold. I am a friendly person, good thinker, I can work for longer hours without any break, only if I'm interested in that...My life style is very simple.

PART I FUNCTIONS IN C

 In the previous tutorial you learn some important questions
 now in this tutorial you will be introduce to function
 its uses in C programming and also you will learn 
 function definition, function declaration with example.



                                                   FUNCTION
A function is a group of statements that together perform a specific task. Every C program has at least one function, which is main(), Dividing complex problem into small components makes program easy to understand and use.

   USES OF C FUNCTIONS:
1)There is no limit in calling C functions to make use of same 
    functionality wherever required.

2)We can call functions any number of times in a program and
   from any place in a program.

3)A large C program can easily be tracked when it is divided into functions.

4)C functions are used to avoid rewriting same logic/code again and again 
   in a program.

         C function declaration, function call and function definition:

  1)Function definition – This contains all the statements to be executed.
  2)Function call – This calls the actual function.
  3)A function declaration tells the compiler about a function name and
   how to call the function.

                                       PROGRAM TO IMPLEMENT FUNCTION:
                                                             OUTPUT


    HOW TO CALL C FUNCTION IN A PROGRAM:
    1)Call by value: In call by value method, the value of the variable is
       passed to the function as parameter. The value of the actual parameter 
       can not be modified by formal parameter. value of actual parameter is 
       copied to formal parameter.

                                      PROGRAM TO IMPLEMENT CALL BY VALUE:
    swap(m,n); is a function call.
                                                                     OUTPUT
                         

2)Call by reference: In call by reference method, the address of the variable
   is passed to the function as parameter. The value of the actual parameter
   can be modified by formal parameter. Same memory is used for both actual 
   and formal parameters since only address is used by both parameters.
                               PROGRAM TO IMPLEMENT CALL BY REFERENCE:

                                                                  OUTPUT








Post a Comment

0 Comments