Code and assertions are right 
16. Verify the correctness of the following program segment with the assertions shown. x=z+1 y=x+2 y-6) if y >0 then...
17. hy the correctness of the following program segment with the precondition and postcondition shown {x60 if x > 0 then y = 2 ** else y=(-2) *x end if {y >0} 18. Verify the correctness of the following program segment to compute x, the absolute value of x, for a nonzero number x. {r* 0 if x >= 0 then abs = r else abs = -x end if
Prove whether or not the program segment x≔3 z≔x-y+2 if y>0 then z≔z+3 else z≔2 is partially correct with respect to the initial assertion y=4 and the final assertion z=6
Problem 8)(Java code) Give the output of the following program segment if: (a) x=1 and y=1, (b) x=2 and y=2. if (x > 1) if (y > 2) Sysytem.out.println(2*x-y); else Sysytem.out.println(2*x+y); else if (y > 2) Sysytem.out.println(x-y); else Sysytem.out.println(x+y);
2. (15 marks) Consider the following program: >> Precondition: x and y E Z. Postcondition: Return the sum x + y. add(x, y): 1. if x == 0: 2. return y 3. elif x > 0: 4. return add(x - 1, y) + 1 5. else: 6. return add(x + 1, y) - 1 Prove that this program is correct in terms of its specification.
. Given x-0, y = 0 and z-1, what is the value of x, y, z after executing the following code? if(x) If(y) Z-3 else Z- 2
7. Write the following code segment in MARIE's assembly language (If-Else): If x < Y Then X = Y - X; Y = Y + 1; Else X = Y; Y = 0; Endif;
avr
assembly please
3) Write an assembly program that is algorithmically equivalent to the following C++ code. Treat the variable y as a short int (16 bits) 1 int y; 2 for (int x = 2; x <= 20; x = x + 2) { 3 ¡f (x < 18) { 4 5 у 24 6 else f 7 8 9
3) Write an assembly program that is algorithmically equivalent to the following C++ code. Treat the variable y as...
Multiple Choices (1 point each) to the program segment at the right is 85, what is its output? 1 If the input the scanf("%d", & s); a. if (s> 90) else if (s>-70) else if (s >= 80) else printf"Aln"); printf("Cn"); printf"BIn") printf"DIn") C. d. e. B, C 2. Assume a 12 and b 13, the if statement if(a<b) else printfl BIn") printf"A In" printf"Bin") a. displays A. b. displays A and B c. display B. d. causes a run-time...
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
5. Verify Stokes' theorem for F(x,y, z) = 2zi +3xj + 5yk over the paraboloid z = 4 -x2-y2 z≥06. Verify the divergence theorem for F(x, y,z) = zk over the hemisphere : z = √(a2-x2-y2)