#include <iostream>
using namespace std;
int fun(int *k);
int main() {
int i = 10, j = 10, sum1,sum2;
sum1 = (i / 2) + fun(&i);
sum2 = fun(&j) + (j / 2);
cout<< sum1<< " "<<sum2<<endl;
}
int fun(int *k) {
*k += 4;
return 3 * (*k) - 1;
}
I have to convert my code to Java Code I already converted but i couldn't find my mistake i cannot point variables to each other..
public class System{
public static void main(String[] args) {
int i = 10;
int j = 10;
int sum1 = (i / 2) + fun(k.value=i);
int sum2 = fun(k.value=j) + (j / 2);
System.out.println("%d%d",sum1,sum2 );
}
public static int fun(int k) {
intobj k;
int k= new k();
k.value += 4;
return 3 * (k.value) - 1;
}
}
This is my java code when i look at the int sum1 = (i / 2) + fun(k.value=i); int sum2 = fun(k.value=j) + (j / 2); part isn't true about point to true values. How can i solve that pointers problem. Thank you.