CSc 265 - Lab Exercise 4 Team Name: Team Members: contents of file "intersection.c": #include int findpos(int a[],int n,int x) { int i; for (i = 0; i < n; i++) if (a[i] == x) return i; return -1; } void shiftleft(int a[],int startpos,int endpos) { int i; for (i = startpos; i < endpos; i++) a[i] = a[i+1]; } void intersection(int a[],int *alen,int b[],int blen) { int i; for (i = *alen-1; i >= 0; i--) { if (findpos(b,blen,a[i]) == -1) { shiftleft(a,i,*alen-1); (*alen)--; } } } main() { int a[] = {1,3,5,7,9}; int alen = 5; int b[] = {1,5,9}; int blen = 3; int i; intersection(a,&alen,b,blen); for (i = 0; i < alen; i++) printf("a[%d]: %d ",i,a[i]); printf("\n"); abort(); } To the left is the corrected code from last week's exercise, which computes the intersection of the arrays a[] and b[], stores it in a[], then outputs the contents of a[]. The abort() function call at the end of the main function causes the program to generate a core dump, which is required for the dbx debugger. For the questions below, assume the following commands have been executed: cc -g -o intersection intersection.c unlimit coredumpsize intersection dbx intersection core What is the result of entering the following commands (questions 1-5)? 1) whatis a 2) whereis i 3) which i 4) print a[0]*10 - b[2] 5) &a/5D 6) How would you display the source code for the intersection function? 7) How could you display the contents of the array a[] (5 elements) plus the contents of the 8 bytes immediately following a[]? 8) What sequence of commands would you use to run the program and stop execution after the 7 has been eliminated from a[] and then display the contents of the 4th element of a[]? (Hint: use stop in [functionname]) 9) What sequence of commands would you use to run the program and generate trace output every time the variable alen is changed? How many times does this occur?