Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / 1) Compute the weakest precondition for each of the following assignment statements and post-conditions: a

1) Compute the weakest precondition for each of the following assignment statements and post-conditions: a

Computer Science

1) Compute the weakest precondition for each of the following assignment statements and post-conditions:

a. a = 2 * (b - 1) - 1 {a> 0}

b. b = (c + 10) / 3 {b> 6}

c. a = a + 2 * b - 1 {a> 1}

d. x = 2 * y + x - 1 {x> 11}

 

2. Prove the correctness of the program below

{n> 0}

count = n;

sum = 0;

while count <> 0 do

sum = sum + count;

count = count - 1;

end

{sum = 1 + 2 +. . . + n}

 

3. The fun function is defined as

int fun (int * k) (

* k + = 4;

return 3 * (* k) - 1;

}

Suppose fun is used in a program as follows:

void main () {

int i = 10, j = 10, sum1, sum2;

sum1 = (i / 2) + fun (& i);

sum2 = fun (& j) + (j / 2);

}

What is the value of sum1 and sum2 if

a. operand in an expression that evaluates from left to right?

b. operand in an expression that evaluates from right to left?

 

4. Rewrite the pseudocode segment using the structure structure in the following language:

k = (j + 13) / 27

loop:

if k> 10 then goto out

k = k + 1

i = 3 * k - 1

goto loop

out:. . .

a. C, C ++, Java, or C #

b. Python

c. Ruby

 

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE