Wednesday, 21 September 2016

Function Example print a'=a+b and b'=mod a-b

#include <stdio.h>

void update(int *a,int *b) {
    int x=*a,y=*b;       
    *a=x+y;
    if(x>y)
        *b=x-y;
    else
        *b=y-x;
}

int main() {
    int a, b;
    int *pa = &a, *pb = &b;
   
    scanf("%d %d", &a, &b);
    update(pa, pb);
    printf("%d\n%d", a, b);

    return 0;
}

No comments:

Post a Comment