0
Why its shows error while try to pass the value as normal interger a and b into the function update instead of passing ptr var?
I'll mention code here plz someone help me to fig out the doubt #include<studio> void update(int *a ,int *b){ *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); Update(a,b); Return 0; }
1 Resposta
+ 3
please kindly write your code on code play ground and link it here
edit, you need to pass the address of the variable as parameter in the function, wince its not an array
/*Why its shows error while try to pass the value as normal interger a and b into the function update instead of passing ptr var?
I'll mention code here plz someone help me to fig out the doubt */
#include<stdio.h>
#include <stdlib.h>
int update(int *a ,int *b){ *a+=*b; *b=abs(*a -(2* *b)); return *b;}
int main(){int a,b;
//int *pa=&a,*pb=&b;
scanf("%d %d", &a, &b);
//update(pa,pb);
printf("%d",update(&a,&b));
return 0;
}
thats your code now working fine