

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Name (printed):
Student ID #:
Section # (or TA’s: name and time)
The output, when a 3 is passed in, is: |The output, when a 5 is passed in, is: | 3 4 5 | 5 6 7 8 9 2 3 4 | 4 5 6 7 8 1 2 3 | 3 4 5 6 7 | 2 3 4 5 6 | 1 2 3 4 5
#include <stdio.h>
int f1(int i){ int j = 5, k = 0; for (j = 10; j > i; j--){ k+=i; } return k; } int f2(int i){ int j, sum=i; for (j = 1; j < i; j++){ printf("%d: sum = %d\n",j,sum); sum +=i; } return sum; } int main(){ printf("%d\n",f1(3)); printf("%d\n",f2(5)); return 0; }