int main() {
int a, b;
cin>>a;
cin>>b;
update(&a,&b);
cout<<a;
cout<<b;
return 0;
}
i am trying above code it uses concept of pointers but not getting the expected output what wrong here
input
9
5
expected output
14
4
getting output as 115
Note that in the function update, when you are assigning a new value to q, you are using the value of p that you already changed on the previous line. The calculation is not q=9-4 , but is q=15-4