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;
}
Join

Search articles

Search titles, tags and article content.

    You've successfully subscribed to Developer Insider
    Your account is ready. Welcome to Developer Insider
    Welcome back! You've successfully signed in
    Success! Your account is fully activated, you now have access to all content.