Pointers in C

Sort by

recency

|

679 Discussions

|

  • + 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;
    }
    
  • + 0 comments

    include

    include

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

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

    return 0;
    

    }

  • + 0 comments

    include

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

    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

    include

    include

    void update(int *a,int *b) {

    *a= (*a + *b);
    *b= abs(*a - *b- *b); 
    

    } int main() { int a, b;

    scanf("%d", &a);
    scanf("%d", &b);
    int *pa = &a, *pb = &b;
    update(pa, pb);
    printf("%d\n", a);
    printf("%d\n", b);
    
    return 0;
    

    }