CSE 142 Quiz 6
July 27th, 2000
Name:
SID:
Answer the following question:
What does the following program output? Assume it compiles cleanly.
#include <stdio.h> #define LENGTH 5 void switcheroo(int numbers[]) { int i; for (i=0; i<LENGTH; i++) numbers[i] = i+1; numbers[LENGTH-1] = 0; } int main(void) { int nums[LENGTH]; int i; for (i=0; i<LENGTH; i++) { nums[i] = i; printf("%d, ", nums[i]); } printf("\n"); switcheroo(nums); for (i=0; i<LENGTH; i++) printf("%d, ", nums[i]); printf("\n"); return 0; } 0, 1, 2, 3, 4, 1, 2, 3, 4, 0,