944,122 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 806
  • C++ RSS
Sep 6th, 2007
0

help needed

Expand Post »
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:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hassan_kh is offline Offline
12 posts
since Sep 2007
Sep 6th, 2007
0

Re: help needed

I'm guessing a and c belong to the set of natural numbers, could be wrong though.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Sep 6th, 2007
0

Re: help needed

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005
Sep 6th, 2007
0

Re: help needed

Thank you so much .
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hassan_kh is offline Offline
12 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: help needed
Next Thread in C++ Forum Timeline: Help:What would happen when the code is run?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC