source: CIVL/examples/languageFeatures/chooseInt.cvl@ 90dd7d7

1.23 2.0 main test-branch
Last change on this file since 90dd7d7 was 4b8fe131, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

Translate function calls in the form of $choose_int(n) in to ChooseStatement, and add a test accordingly.

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

  • Property mode set to 100644
File size: 203 bytes
Line 
1#include <civlc.h>
2
3int sum(int n){
4 int sum = 0;
5 for(int i = 1; i <= n; i++){
6 sum += i;
7 }
8 return sum;
9}
10
11void main(){
12 int k = $choose_int(5);
13 int result = sum(k);
14 $assert result == k*(k+1)/2;
15}
Note: See TracBrowser for help on using the repository browser.