Results 1 to 3 of 3

Thread: Call by Value and Call by Reference

  1. #1
    Moderator
    Join Date
    Oct 2005
    Answers
    305

    Call by Value and Call by Reference

    Call by Value and Call by Reference

    In this tutorial you will learn about C Programming - What is difference between call by value and call by reference in function?

    The arguments passed to function can be of two types namely
    1. Values passed
    2. Address passed
    The first type refers to call by value and the second type refers to call by reference.


    For instance consider program1


    Read More...


    Last edited by admin; 06-20-2012 at 09:19 PM.

  2. #2
    Contributing Member
    Join Date
    May 2006
    Answers
    82

    Re: Call by Value and Call by Reference

    It was useful information about passing arguments to functions. In call by value argument gets passed as variables and in call by reference address gets passed. Does it mean if we use call by reference the execution time would be faster for the function since we the address gets accessed directly. If not why is it so?


  3. #3
    Junior Member
    Join Date
    Jun 2009
    Answers
    1

    Re: Call by Value and Call by Reference

    call by value:

    fun(5);

    call by reference

    fun(&a);


    definition call by value

    int fun(int a)
    {
    int b;
    b= a+ 2;
    return(b);
    }

    call by reference

    int fun(int *a)
    {
    b=(*a )+ (*a)
    return b;
    }


  4.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact