Sort by

recency

|

1161 Discussions

|

  • + 0 comments
    void update(int *a,int *b) {
        *a = *a + *b;
        *b = abs((*b)*2 - *a); 
    }
    
  • + 0 comments
    #include <stdio.h>
    #include <stdlib.h>
    
    void update(int *a,int *b) {
        // Complete this function
        *a = *a + *b;
        *b = abs(*b - (*a - *b));
    }
    
  • + 0 comments

    use cpp 20

    include

    include

    include

    include

    include

    using namespace std;

    // Function to update sum and absolute difference via pointers void update(int *a, int *b) { int sum = *a + *b; int diff = *a - *b; if (diff < 0) diff = -diff; // Absolute value *a = sum; *b = diff; }

    int main() { int a, b; cin >> a >> b; update(&a, &b); cout << a << endl << b << endl; return 0; }

  • + 0 comments
    void update(int *a,int *b) {
        int temp = *a; // copy the value of a 
        *a = *a + *b; 
        *b = abs(temp - *b);      
    }
    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;
    }
    
  • + 0 comments

    Here is Pointers in c++ solution - https://programmingoneonone.com/hackerrank-pointer-solution-in-cpp.html