This assignment is due in class on 8 October or may be uploaded to Homework 6 on moodle by 2:00 PM on 8 October.
Writing with the goto
Below are two program segments taken from last year’s final exam:
if (i > 5)
{
i++ ;
}
if (sum > 5)
{
sum++ ;
}
sum = 0 ;
for (i=0; i<100; ++i)
{
if (V[i] > 0)
{
sum = sum + V[i] ;
}
}
Rewrite these two program into C without 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.)
You should assume that all the variables of these programs are integers.