12/05/05 Lecture Notes CISC105 Exam 1 multiple choice grading * It has been established that there was _one_ problem with the exam 1 multiple choice grading: some of the grades were originally associated with the wrong userids. This affected only userids from M through Z. * It is possible that there was ALSO a separate problem with one or more of the answer keys. It was not possible to look into that until the original problem was solved. * So, now, please look over your scantron sheet, and compare it with the online answer keys. If you find a discrepancy, bring it to Prof. Conrad during office hours or make an appointment. SENDING EMAIL IS NOT GUARANTEED TO GET A CORRECTION MADE (email is backed up with over 300 unread emails). E01 19 mc E02 15 mc Pass by reference vs. Pass by value Check out http://copland.udel.edu/~pconrad/cisc105/05F/examInfo/E02_practiceQuiz/quiz1.html Then, note the following: void foo(int w); int bar(int x); void fum(int *y); int fiddle(int *z); foo and bar are pass by value fum and fiddle are pass by reference foo and fum .... what do they have in common? they don't return anything... they have a return type of void bar and fiddle .... what do they have in common? both return an int value int a, b, c, d; a = 5; b = 6; c = 7; d = 8; b = ____ ( &c); Which of the functions, foo, bar, fum, fiddle could be used to fill in the blank? If you tried to use either foo or fum, you would get a syntax error... you MUST have a return value if you are assigning the return value to the left hand side. printf("%d\n", ____ (a)); Which one? bar printf("I'm gonna call a function\n"); ____ (5); This is a trick question. But, for sake of argument, which one could I call? The best answer is foo, because since I'm not using the return value, a void function is probably called for. Second the answer is probably foo because I'm passing in a literal int (5), so I probably a parameter of type int. However, there are two details: * It is possible to call a function that returns a value, and ignore the value returned. That is, just because someone throws you a ball, doesn't mean you have to catch it.