FALL 07 FINAL SOLUTION

FALL 07 FINAL SOLUTION - Name ECE264 Advanced C Programming...

This preview shows pages 1–4. Sign up to view the full content.

December 12, 2007 Name _________________________________ ECE264 Advanced C Programming Final Exam Solve the following problems. The number of points for each problem is shown next to the problem and in the table below. The outcomes corresponding to each question are also shown. Use only the space provided to solve each problem. Problem Points Outcome iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 1 (a) / 7 2 (b) / 7 (c) / 8 (d) / 8 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 2 (a) / 5 3 (b) / 5 (c) / 5 (d) / 10 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 3 (a) / 6 1 (b) / 6 (c) / 6 (d) / 7 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 4 / 10 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 5 (a) / 5 (b) / 5 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii Total / 100 c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
- 2 - Problem 1 (30 points) What will the following program print in each one of the calls to the function printst()? #include <stdio.h> #define NA 3 #define NB 4 #define NC 5 struct st { int a[NA],b[NB],c[NC]; }; int main() { int i; struct st st; void stfunc1(struct st, int, int, int); void stfunc2(struct st *, int, int, int); struct st stfunc3(struct st, int, int, int); void stfunc4(int [], int, int); void printst(struct st); for(i=0;i<NA;i++) st.a[i]=0; for(i=0;i<NB;i++) st.b[i]=0; for(i=0;i<NC;i++) st.c[i]=0; stfunc1(st,1,2,3); printst(st); /* (a) */ for(i=0;i<NA;i++) st.a[i]=0; for(i=0;i<NB;i++) st.b[i]=0; for(i=0;i<NC;i++) st.c[i]=0; stfunc2(&st,2,3,4); printst(st); /* (b) */ for(i=0;i<NA;i++) st.a[i]=0; for(i=0;i<NB;i++) st.b[i]=0; for(i=0;i<NC;i++) st.c[i]=0; st=stfunc3(st,4,5,6); printst(st); /* (c) */
- 3 - for(i=0;i<NA;i++) st.a[i]=0; for(i=0;i<NB;i++) st.b[i]=0; for(i=0;i<NC;i++) st.c[i]=0; stfunc4(st.a,NA,5); stfunc4(st.b,NB,6); stfunc4(st.c,NC,7); printst(st); /* (d) */ } void stfunc1(struct st st, int n1, int n2, int n3) { int i; for(i=0;i<NA;i++) st.a[i]=n1; for(i=0;i<NB;i++) st.b[i]=n2; for(i=0;i<NC;i++) st.c[i]=n3; } void stfunc2(struct st *pst, int n1, int n2, int n3) { int i; for(i=0;i<NA;i++) pst->a[i]=n1; for(i=0;i<NB;i++) pst->b[i]=n2;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 15

FALL 07 FINAL SOLUTION - Name ECE264 Advanced C Programming...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online