Pointers in C

Sort by

recency

|

682 Discussions

|

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

    solving with 2s compliment

    void update(int *a,int *b) {
        int sum = *a + *b;  
        int diff = *a - *b;
          
        *a = sum;  
        if((diff) < 0)
            *b = (~diff)+1;
        else
            *b = diff;     
    }
    
  • + 0 comments

    Here is pointers in c problem solution - https://programmingoneonone.com/hackerrank-pointers-in-c-problem-solution.html

  • + 0 comments

    Great explanation of pointers in C! 🖥️ Understanding how pointers work is essential for managing memory and modifying variables within functions. Betbricks7 com Login

  • + 0 comments
    #include<stdio.h>
    #include<stdlib.h>
    
    void update(int *a, int *b)
    {
        int temp = *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;
    }