Pointers in C

Sort by

recency

|

686 Discussions

|

  • + 0 comments

    include

    include

    void update(int *a, int *b) { int sum = *a + *b; int difference = abs(*a - *b); *a = sum; *b = difference; }

    int main() { int a, b; scanf("%d %d", &a, &b); update(&a, &b); printf("%d\n%d", a, b); return 0; }

  • + 0 comments
    void update(int *a,int *b) {
        // Complete this function
        int s, d;
        s = *a+*b;
        d = *a-*b;
            
        *a = s;
        *b = d;
        
        if (*b < 0) {
            *b = -(*b);
        }
    }
    
  • + 0 comments
    void update(int *a,int *b) {
        int sum,diff;
        
        sum = *a + *b;
        
        (*a >*b)?(diff = (*a - *b)):( diff = (*b-*a));
        
        *a = sum;
        *b = diff;
    }
    
  • + 0 comments

    C is such a powerful and foundational language—great for understanding how computers really work. betguru 247 net sign up

  • + 0 comments
    void update(int *a,int *b) {
        *a = (*a + *b);
        (*a > 2*(*b))? (*b = (*a - 2*(*b))): (*b = (2*(*b)-(*a))); 
    
    }