Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 10-15-2004, 10:54 AM   #1 (permalink)
 
Newb Techie

Join Date: Oct 2004

Posts: 14

LauraP

Default Help with JAVA coding

...If you have a function as follows:
int fun(int *k)
{
*k +=4;
return 3*(*k)-1;
}
...and if fun is used in the program below:
void main()
{
int i = 10;
int j = 10;
int sum1;
int sum2;

sum1 = (i/2)+ fun(&i);
sum2 = fun(&j) + (j/2);
}
...what is the values of sum1 and sum2 if the operands in the expressions are
looked at from left to right and right to left?

Could someone please help me with this question? I would highly appreciate it

Thanks!
LauraP is offline  
Old 10-18-2004, 11:16 PM   #2 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

I don't remember Java having pointers....now then if you're asking this question and ignoring the pointers the values are:

sum1 = 46
sum2 = 46

But I could be wrong because I did this really fast and late at nigh
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 10-19-2004, 12:04 PM   #3 (permalink)
 
Newb Techie

Join Date: Oct 2004

Posts: 14

LauraP

Default

Thanks for your help I appreciate it
LauraP is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On