Pointers in C

Sort by

recency

|

671 Discussions

|

  • + 0 comments

    include

    include

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

    int main() { int a, b; int *pa = &a, *pb = &b;

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

    }

  • + 0 comments
    #include <stdio.h>
    
    void update(int *a,int *b) {
        *a = *a+*b;
        *b = abs(*a-*b-*b);
        //The extra *b is because *a value is changed above by adding *b
        //So to equalize the effect we subtract *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

    hiii

  • + 0 comments

    void update(int *a,int *b) { *a= *a + *b; *b= *a - *b - *b; if(*b <= 0){ *b = -*b; } else { *b; } // Complete this function
    }

  • + 0 comments

    Thanks for sharing Valuable post. windaddy com