Sort by

recency

|

1144 Discussions

|

  • + 0 comments

    void update(int *a,int *b) { int sum= (*a)+(*b); int diff= abs((*a)-(*b));
    (*a)=sum; (*b)=diff; } this may help :)

  • + 0 comments

    Hey, this is my code. Insights would be appreciated. Happy learning!

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

    Using Ternary Operator

    void update(int *a,int *b) {
        int x=*a + *b;
        int diff=*a-*b;
        int y=(diff<0 ? -diff : diff;
        *a=x;
        *b=y;
    }
    
  • + 0 comments

    `Hey guys :

    include

    void update(int *a,int *b) { // Complete this function
    int sum = *a + *b; int sub = abs(*a - *b);

    *a = sum;````
    *b = sub;
    

    } `

  • + 0 comments

    Simplest solution is below,

    include

    using namespace std;

    void update(int *pa,int *pb){ int temp = *pa; *pa = *pa + *pb; *pb = temp > *pb ? temp - *pb : *pb-temp; }

    int main(){ int a,b; cout <<"Enter a & b: "; cin >>a>>b; update(&a,&b); cout <<"sum: "<