This assignment is due in class on 21 October or may be uploaded to Homework 8 on moodle by 12:30 PM on 21 October.
Writing with the goto
Below are two silly functions:
void silly1(int i, sum *) { if (i != 5) { *sum = *sum + i ; } if (*sum > 3) { *sum = -*sum ; } }
void silly2(const int *V, int n) { int c255 = 0 ; for (int i = 0; i < n; ++i) { if (V[i] == 255) { ++c255 ; } } return c255 ; }
Rewrite these two functions into C with using only two control
structures:
goto label
;
if (expression) goto label
;
This means you can’t use the
for
, while
, switch
,
or the statement block delimiters {
or }
.
(The block delimters aren’t really needed in either of the
two examples anyway.)