Pointers in C | HackerRank
Problem Link : Pointers in C
Solution :
Develop by Samsus Salehin Sabbir
- #include <stdio.h>
- void update(int *a,int *b) {
- // Complete this function
- int temp = *a;
- *a = (*(a))+(*(b));
- *b = abs(temp-(*(b)));
- //return temp,temp2; //no need to return beacouse auto return same address
- }
- int main() {
- int a, b;
- int *pa = &a, *pb = &b; // create pointer and store address
- scanf("%d %d", &a, &b);
- update(pa, pb); // passing address
- printf("%d\n%d\n", a, b); //
- return 0;
- }
No comments