Answers for "how to substract two numbers to give positive outcome in c++ by the hep of pointers"

C++
-1

how to substract two numbers to give positive outcome in c++ by the hep of pointers

#include <cstdio>
#include <cstdlib>

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;
}
Posted by: Guest on March-07-2020

Code answers related to "how to substract two numbers to give positive outcome in c++ by the hep of pointers"

Browse Popular Code Answers by Language