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:

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

I'm guessing a and c belong to the set of natural numbers, could be wrong though.

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.

Thank you so much .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.