HackerRank Pointers in C solution YASH PAL, 12 July 202416 June 2025 HackerRank Pointers in C problem solution – In this tutorial, we will solve the HackerRank Pointer in C problem or write a program for this problem. in this challenge, we need to write a function that will receive two integer pointers a and b. all we just need is to set the value of a to the sum of a and b, and b to their absolute difference.Using this problem set we are going to learn about the implementation and basic functionalities of pointers in c programming. pointers are always a useful functionality in c because they share the address as a value.What is so special about pointer? A pointer always used to hold the address of any other variable. so we don’t need to remember the value of any variable.Solutions Explained in Video HackerRank Pointers in C problem solutionHackerRank Pointers in C solutionHackerRank Pointers in c solution.#include <stdio.h> void update(int *a,int *b) { // Complete this function *a=*a+*b; *b=abs(*a-(2**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; }#include <stdio.h> void update(int *a,int *b) { // Complete this function *a=*a+*b; *b=abs(*a-(2**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; }ExplanationIn the above program first, we declared a main() function. inside the main function, we have declared two integer variables a and b. after that we have declared a pointer pa and assigned the address of variable a as the value of pointer pa. and the same for the pointer pb. After that using the scanf() function we read the two values from the input string and assigned them to variables a and b. after that we called the update() function with two input arguments of type pointer pa and pb.What is inside the update() function?In the update function, we just assigned the sum of values a and b to *a and then we calculated the absolute difference value to pointer b.Second solution#include <stdio.h> #include <stdlib.h> void update(int *a,int *b) { // Complete this function int t1, t2; t1 = *a + *b; t2 = abs(*a – *b); *a = t1; *b = t2; } 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; }#include <stdio.h> #include <stdlib.h> void update(int *a,int *b) { // Complete this function int t1, t2; t1 = *a + *b; t2 = abs(*a - *b); *a = t1; *b = t2; } 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; }Next problem solution – HackerRank Conditional Statements in C solution C Solutions coding problems solutions Hackerrank Problems Solutions cHackerRank