You are on page 1of 2

1. Write a function to calculate the income tax payable to the user.

The tax is calculated


as per the below table. Write the functional contract to verify the function written. (10
marks)

A. Write a C program to calculate the Income tax for a person based on


his/her total salary. (3)
B. Find the weakest precondition for a person to get a tax of $2000.(4)
C. For the input condition (salary = $35,000), check the validity in Frama-C.
(3)

2. Derive the weakest precondition for the given program code using Loop Invariants, for
the post condition {y=c}. Derive and verify the intraloop, exit loop and start conditions.
Verify them in altergo.
Precondition: c>=0
int computesum(int c){
x=c;
y=0;
While (x > 0) {
x = x -1 ;
y = y+1;
}
return y;
}

(a) Trace out the program state and identify a loop invariant. (3 marks)
(b) Use intra-loop VC and Exit-VC to check whether the loop invariant is weakest
precondition for the given while loop. State the start VC for the pre-condition {x=10}.
(9 marks)
(c)Verify the correctness of the program in Frama-C (3 marks)

You might also like