TDT4160/o456/o5.c

23 lines
286 B
C

#include <stdio.h>
int f(int r0) {
int r2 = 1;
int r1 = 1;
back16:
r2 = r2 * r0;
r0 = r0 - r1;
if (r0 > r1) {
goto back16;
}
return r2;
}
int main() {
int vals[] = {2, 3, 4, 9};
for (int i=0; i<4; i++) {
printf("f( r0=%d ) = %d\n", vals[i], f(vals[i]));
}
return 0;
}