source: CIVL/examples/compare/adder/adder_spec.c

main
Last change on this file 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: 523 bytes
RevLine 
[e936ca5]1#include<stdio.h>
2#include<stdlib.h>
3
4#ifdef _CIVL
5#include <civlc.cvh>
6$input int NB;
7$output double __sum;
8#endif
9
[e6d3df3]10int main(int argc, char *argv[]) {
[e936ca5]11 double sum = 0;
12 int i, n;
13 FILE *fp = fopen("data","r");
14
[5ca4694]15#ifdef _CIVL
16 $assume(1 < argc);
17#endif
[e936ca5]18 n = atoi(argv[1]);
19#ifdef _CIVL
20 $assume(0 < n && n <= NB);
21#endif
22
23 double a[n];
24
25 for (i=0; i<n; i++) fscanf(fp, "%lf", &a[i]);
26 for (i=0; i<n; i++) sum += a[i];
27#ifdef _CIVL
28 __sum = sum;
29#endif
30 printf("result is %lf\n", sum);
31 fclose(fp);
[e6d3df3]32 return 0;
[e936ca5]33}
Note: See TracBrowser for help on using the repository browser.