Hint: Start by deciding what variable or variables should be mentioned in the precondition. Recall the rule for sequences: the precondition for a statement in a sequence is equal to the post-condition for the statement that precedes it. Note: Your answer will involve a relationship between a and b.
{??}
x = 4 * (3 * y – x);
y = 2 * x – 2;
{y > 10}
Consider y > 10
Substitute y = 2 * x – 2 in the above.
2 * x – 2 > 10
2 * x > 10+2
2 * x > 12
x > 6
Substitute x = 4 * (3 * y – x) in the above.
4 * (3 * y – x) > 6
3 * y – x > 6/4
3 * y – x > 1.5
3 * y > 1.5 + x
y > (1.5 + x)/3
Therefore the weakest precondition is y > (1.5 + x)/3.
Compute the weakest precondition for the following sequence of statements, given the stated post condition. Hint:...
3. Find the weakest precondition for the following sequence of statements and its post-condition: a-2b + 1; b = a - 3; {b > 2)
how
do you solve this?
em sets: Compute the weakest precondition for the following sequence of assignment statements and their postconditions (3pts]: a = 3 * (2 * b + a); b = 2 * a - 1 {b > 5}
Compute the weakest precondition for the following statements A. if (x == y) x=x*3 else x=x+1 {x < 0} B. x = 3 * (y + x); y= 3*x ; {y > 6}
Compute the weakest precondition for each of the following assignment statements and postconditions: a = 2 * (b - 1) - 1 {a > 0} b = (c + 10) / 3 {b > 6} Prove that the following grammar is ambiguous (show 2 trees): <S> → <A> <A> → <A> + <A> | <id> <id> → a | b | c
5) Decoders: Given the following circuit, S0 and S1 are computed using a 4-2 priority encoder with the priorities indicated on the figure. (hint: IDLE signal is always 0, if any of the inputs 10,11,12, or 13 is 1) 6 points) 4-to-2 Priority Encoder 10 YO YI 13 IDLE 13> 11 > 12>10 12 Full c Adder So Fill the following table showing the output signals S0 and SI given the input signals w, x, y, a) and z. Prof...
The ability of computers to perform complex tasks is built on combining simple commands into control structures. Of these control structures, blocks, while loop, the do..while loop, and the for loop. A block is the simplest type of structured statement. Its purpose is simply to group a sequence of statements into a single statement. The format of a block is: { } Here are two examples of blocks: { System.out.print("The answer is "); System.out.println(ans); } // This block exchanges the...
Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...
2. Future value Aa Aa E The principal of the time value of money is probably the single most important concept in financial management. One of the most frequently encountered applications involves the calculation of a future value. The process for converting present values into future values is called . This process requires knowledge of the values of three of four time-value-of-money variables. Which of the following is not one of these variables? T O The interest rate (1) that...
R studio #Exercise : Calculate the following probabilities : #1. Probability that a normal random variable with mean 22 and variance 25 #(i)lies between 16.2 and 27.5 #(ii) is greater than 29 #(iii) is less than 17 #(iv)is less than 15 or greater than 25 #2.Probability that in 60 tosses of a fair coin the head comes up #(i) 20,25 or 30 times #(ii) less than 20 times #(iii) between 20 and 30 times #3.A random variable X has Poisson...
Must be written in C++ Bank Charges A bank charges $15 per month plus the following check fees for a commercial checking account: $0.10 per check each for fewer than 20 checks (1-19) $0.08 each for 20–39 checks $0.06 each for 40–59 checks $0.04 each for 60 or more checks Write a program that asks for the number of checks written during the past month, then computes and displays the bank’s fees for the month. Input Validation: Display an error...