We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I included <stdlib.h> to use abs() function. Here you can see my code snippet for your reference. If you have any idea feel free to comment.
#include<stdio.h>#include<stdlib.h>voidupdate(int*a,int*b){//declaring temporary variable to store the valuesintc,d;c=*a+*b;d=*b-*a;//assigning value to pointer variable*a=c;*b=d;}intmain(){inta,b;int*pa=&a,*pb=&b;scanf("%d %d",&a,&b);//function callingupdate(pa,pb);//using abs() to return positive integer according to requirementprintf("%d\n%d",a,abs(b));return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pointers in C
You are viewing a single comment's thread. Return to all comments →
Addition and subtraction using pointers
I included
<stdlib.h>
to useabs()
function. Here you can see my code snippet for your reference. If you have any idea feel free to comment.