source: CIVL/examples/compare/adder/ub_adder_spec.c@ 7d77e64

main test-branch
Last change on this file since 7d77e64 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: 452 bytes
Line 
1#include<stdio.h>
2#include<stdlib.h>
3#include <civlc.cvh>
4
5#pragma CIVL ACSL
6
7$input int N;
8$assume(N >= 0);
9$input int a[N];
10$output double __sum;
11
12
13int main(int argc, char *argv[]) {
14 double sum = 0;
15 int i, n = N;
16
17 /*@ loop invariant 0 <= i <= n;
18 @ loop invariant sum == \sum(0, i-1, \lambda int t; a[t]);
19 @ loop assigns sum, i;
20 @*/
21 for (i=0; i<n; i++) sum += a[i];
22 __sum = sum;
23 printf("result is %lf\n", sum);
24 return 0;
25}
Note: See TracBrowser for help on using the repository browser.