source: CIVL/mods/dev.civl.abc/examples/macro/adder.c

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

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

  • Property mode set to 100644
File size: 576 bytes
RevLine 
[aad342c]1#include<stdio.h>
2
3// CIVL has a predefined macro _CIVL
4#ifdef _CIVL
5 // CIVL will make N an input variable
6 // automatically
7 #include <civlc.cvh>
8 $input int N;
9 $assume(0 < N && N < 10);
10#else
11 // if not runned by CIVL,
12 // then make N a macro.
13 #define N 100
14#endif
15
16int input[N];
17int sum = 0;
18
19int main(){
20 for(int i = 0; i < N; i++)
21 input[i] = i;
22 for(int i = 0; i < N; i++)
23 sum += input[i];
24#ifdef _CIVL
25 // assertion only added for CIVL
26 $assert(sum == N*(N-1)/2);
27#endif
28 printf("N = %d, sum = %d\n", N, sum);
29 fflush(stdout);
30 return 0;
31}
Note: See TracBrowser for help on using the repository browser.