source:
CIVL/mods/dev.civl.com/examples/languageFeatures/comma.cvl@
cb4d4f4
| Last change on this file since cb4d4f4 was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 250 bytes | |
| Line | |
|---|---|
| 1 | /* This example demonstrates the use of comma operators. |
| 2 | * It has no violation. |
| 3 | */ |
| 4 | #include<civlc.cvh> |
| 5 | |
| 6 | $input int n=5; |
| 7 | |
| 8 | void main() { |
| 9 | int i,j, k; |
| 10 | |
| 11 | k = 0; |
| 12 | for (i=0, j=1; i<=n; i++,j++) { |
| 13 | k += i*j; |
| 14 | } |
| 15 | $assert(k == n*(n+1)*(n+2)/3); |
| 16 | } |
Note:
See TracBrowser
for help on using the repository browser.
