Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

was given this problem in an interview...

 

anyone got any ideas....

 

What initial values of a and c are required such that the final values of a and b are:

 

 

a = 32

b = 4

 

 

int a,b,c

 

a = ?

b = 0

c = ?

 

for( b=0; a<12; b++ )

{

a = (a+a) * c;

}

  • *Experts*
Posted

If I were given that in an interview I'd have asked "Seriously?" There's no point in giving that in an interview. If they said "Yes, seriously" then I'd have walked out.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
a = 2

c = -1

 

 

can i ask u how long it took u to do that or what way of thinking help u solve the problem,,, i feel so stupid, i've been looking at this for an hour

Posted

32 = 16ac^4

2 and 1 are the only integers that fit that equation and setting c to be negative flips the sign every other pass so that on the third iteration a is -16.

 

It's pretty straight forward but I agree with Nerseus that it is a completely ridiculous question.

"Who is John Galt?"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...