Pointers in C

  • + 0 comments

    Pointer in C.

    Here is an Easy Solution of the problem :

    #include <stdio.h>
    #include <stdlib.h>
    
    int update(int *a, int *b) {
        int temp_a = *a, temp_b = *b;
    
        *a = temp_a + temp_b;
        *b = abs(temp_a - temp_b);
    }
    
    int main() {
    
        int frst, scnd;
        int *p_frst = &frst, *p_scnd = &scnd;
    
        scanf("%d %d", &frst, &scnd);
    
        update(p_frst, p_scnd);
    
        printf("%d\n%d\n", frst, scnd);
    
        return 0;
    }