source: CIVL/examples/arithmetic/assoc.cvl

main
Last change on this file was b689afd, checked in by Stephen Siegel <siegel@…>, 4 weeks ago

Getting rid of unused examples that are not good and starting to clean
up others.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@6036 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 565 bytes
RevLine 
[06b8536c]1/* assoc.cvl: adds the elements of an array in two different
2 * orders, and checks the results agree. This relies on the
3 * use of real arithmetic, as opposed to floating-point
4 * arithmetic.
5 *
6 * Should be run at commandline specifying an upper bound on
7 * the length of the array. Example:
8 * civl verify -inputB=100 assoc.cvl
9 */
[0baeebd]10$input int B = 10;
[06b8536c]11$input int n;
[f3282f0]12$assume(0<n && n<B);
[793cfc2]13$input double a[n];
14
15void main() {
16 double s0 = 0.0;
17 double s1 = 0.0;
[06b8536c]18
[793cfc2]19 for (int i = 0; i < n; i++) {
20 s0 += a[i];
21 s1 += a[n-1-i];
22 }
[d980649]23 $assert(s0 == s1);
[793cfc2]24}
Note: See TracBrowser for help on using the repository browser.