HackerRank C- Pointers in C




You have to complete the function void update(int *a,int *b), which reads two integers as argument, and sets with the sum of them, and b with the absolute difference of them.



  1. #include <stdio.h>
  2. void update(int *a,int *b) {
  3. *a=*a+(*b);
  4. *b=(*a)-(*b)-(*b);
  5. if(*b<0)
  6. {
  7. *b=*b*(-1);
  8. }
  9. }
  10. int main() {
  11. int a, b;
  12. int *pa = &a, *pb = &b;
  13. scanf("%d %d", &a, &b);
  14. update(pa, pb);
  15. printf("%d\n%d", a, b);
  16. return 0;
  17. }
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube