Arithmetic Operations || call by reference || Pointers || C Programming
In this, we are going to perform arithmetic operations using call by reference by using Pointers in C Programming Language.

#include <stdio.h>
void sum(int x, int y, int *r)
{
    *r = x + y;
}

void difference(int x, int y, int *r)
{
    *r = x - y;
}

void product(int x, int y, int *r)
{
    *r = x * y;
}

void division(int x, int y, int *r)
{
    *r = x / y;
}

int main()
{
    int x, y, r;
    printf("Enter two numbers: ");
    scanf("%d %d", &x, &y);

    sum(x, y, &r);
    printf("Sum is %d\n", r);

    difference(x, y, &r);
    printf("Difference is %d\n", r);

    product(x, y, &r);
    printf("Product is %d\n", r);

    division(x, y, &r);
    printf("Division is %d\n", r);
    return 0;
}

//..........Coded by Ananya Maurya

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post