FALL 07 FINAL SOLUTION

FALL 07 FINAL SOLUTION - December 12, 2007 Name _ ECE264...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
- 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) */
Background image of page 2
- 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;
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This test prep was uploaded on 04/17/2008 for the course ECE 264 taught by Professor Pomeritz during the Spring '08 term at Purdue.

Page1 / 15

FALL 07 FINAL SOLUTION - December 12, 2007 Name _ ECE264...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online