Add numbers using call by reference - C Language Programming

Add numbers using call by reference - C Language Programming

Program in C Language to add numbers using call by reference



Click here to open this program in Turbo C++

/*******************************************************
 Statement - Add numbers using call by reference
 Programmer - Vineet Choudhary
 Written For - http://developerinsider.co
 *******************************************************/

#include <stdio.h>
#include <conio.h>

long add(long *, long *);

void main()
{
    long first, second, sum;
    clrscr();
    
    printf("Input two integers to add\n");
    scanf("%ld%ld", &first, &second);
    
    sum = add(&first, &second);
    
    printf("(%ld) + (%ld) = (%ld)\n", first, second, sum);
    
    getch();
}

long add(long *x, long *y) {
    long sum;
    
    sum = *x + *y;
    
    return sum;
}
You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.