help needed

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 12
Reputation: hassan_kh is an unknown quantity at this point 
Solved Threads: 0
hassan_kh hassan_kh is offline Offline
Newbie Poster

help needed

 
0
  #1
Sep 6th, 2007
Please write down any assumptions or deductions you make, and show all your calculations / workings, completing the task within 10 minutes (guide time).

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;
}

a =

c =

Calculations, working and assumptions:
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: help needed

 
0
  #2
Sep 6th, 2007
I'm guessing a and c belong to the set of natural numbers, could be wrong though.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,511
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1480
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: help needed

 
0
  #3
Sep 6th, 2007
initial values: a = 2 and c = 1

First iteration: a = (2 + 2) * 1 = 4
Second iteration: a = (4 + 4) * 1 = 8
Third iteration: a = (8 + 8) * 1 = 16
Fourth iteration: a = (16 + 16) * 1 = 32

assumptions: none. The code you posted provides all the information needed to figure out the answer.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 12
Reputation: hassan_kh is an unknown quantity at this point 
Solved Threads: 0
hassan_kh hassan_kh is offline Offline
Newbie Poster

Re: help needed

 
0
  #4
Sep 6th, 2007
Thank you so much .
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC