Skip to content

Commit

Permalink
Merge pull request #109 from PurviSaini/issue14
Browse files Browse the repository at this point in the history
Added Pointer.cpp #14
  • Loading branch information
Riddhi9570 authored Oct 1, 2022
2 parents 8000852 + 2e66cb5 commit 5958996
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions C++/Introduction/Pointer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// # Problem : https://www.hackerrank.com/challenges/c-tutorial-pointer/problem
// # Score : 10.0
// # Difficulty : Easy

#include <stdio.h>
#include <stdlib.h>

void update(int *a, int *b)
{
int temp_a = *a;
int temp_b = *b;
*a = temp_a + temp_b;
*b = abs(temp_a - 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 on commit 5958996

Please sign in to comment.