In this Hackerrank Pointers in C problem, we need to develop a C Program in which we need to write a function update that can accept two integer type pointers and didn't return anything. and we need to set crate one variable with the sum of the arguments and the second with the absolute difference.

The absolute difference means in the difference of a-b we just only get the positive value.

HackerRank Pointers in C problem solution

HackerRank Pointers in C problem solution

#include <stdio.h>

void update(int *a,int *b) {
    // Complete this function
    int add, sub;
    add = *a + *b;
    if (*a > *b) {
        sub = *a - *b;
    else sub = *b - *a;
    *a = add;
    *b = sub;

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;