Program to add two numbers using function (Pass by value method)

Output:

You may also like...

4 Responses

  1. laurencev says:

    Would be nice to have syntax highlighting too. Makes a huge difference when learning new language.

  2. Anonymous says:

    1 /* 01_add2num_function.c
    2 * add 2 numbers using function
    3 * pass by refrence
    4 **********************
    5 * I LOVE This Site *
    6 **********************
    7 */
    8
    9 #include
    10
    11 int main()
    12 {
    13 int num1, num2, result;
    14
    15 // get numbers from users
    16 printf(“Please enter 2 numbers: “);
    17 scanf(“%d %d”, &num1, &num2);
    18
    19 // add the numbers using the add() function
    20 result = add(num1, num2);
    21
    22 // print the result to the screen
    23 printf(“%d + %d = %d \n”, num1, num2, result);
    24 }
    25
    26 /* define the add() function
    27 * using reference
    28 */
    29 int add(int no1, int no2)
    30 {
    31 int res;
    32 res = no1 + no2;
    33
    34 return res;
    35 }
    ~

  3. Anonymous says:

    Doing a good job

  1. March 2, 2014

    […] Program to add two numbers using function (Pass by value method) […]

Leave a Reply

Your email address will not be published. Required fields are marked *