Please post formal proof rules used in proof if function is

Please post formal proof rules used in proof if function is correct.

Following are four functions intended to return the a12] a[n] for n 1 (the sum of the first n in an array value a[1] produce correct results, goes wrong. entries of integers). For those that do not explain what For those that do produce correct results, do proof of correctness.

Solution

This is correct.

Proof:

first i = 0 ; j= 0;

loop starts:

first element is added to j

index incremented

loop continues

second element is added to j

index incremented

and so-on the loop continues untill the last element

after the last element n is added to j ; the loop ends

and then j is returned which contains the sum of all first n elements

Please post formal proof rules used in proof if function is correct. Following are four functions intended to return the a12] a[n] for n 1 (the sum of the first

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site