source: CIVL/examples/arithmetic/assoc.cvl@ 397ae5f

main test-branch
Last change on this file since 397ae5f was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

  • Property mode set to 100644
File size: 586 bytes
Line 
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 */
10#include <civlc.cvh>
11$input int B = 10;
12$input int n;
13$assume(0<n && n<B);
14$input double a[n];
15
16void main() {
17 double s0 = 0.0;
18 double s1 = 0.0;
19
20 for (int i = 0; i < n; i++) {
21 s0 += a[i];
22 s1 += a[n-1-i];
23 }
24 $assert(s0 == s1);
25}
Note: See TracBrowser for help on using the repository browser.