On lynx, use down arrow to move to the next question or choice. Hit return to make your selection.
On lynx, use down arrow to move to the next question or choice. Hit return to make your selection.
In the following questions, no syntax errors have put in deliberately. (So, "there is a syntax error" is not the right answer and will receive no credit.) Please mark your final answer clearly. In order to receive partial credit, you must show your work.
In each of the following questions, trace through the program and write down the output of the program. It is important that you write down the output in the order that they would appear when the program is executed.
#include <stdio.h> int dragoon (int, int *) ; int dragoon (int a, int *p) { int b ; b = *p + a ; *p = b / a ; printf("dragoon: a = %d, b = %d, *p = %d\n", a, b, *p) ; return(b) ; } main() { int a = 13, b = 2, c = 9 ; a = dragoon(b, &c) ; printf("main: a = %d, b = %d, c = %d\n", a, b, c) ; }
#include <stdio.h> int yeoman(int []) ; int yeoman(int A[]) { A[1] = 9 ; A[2] = 18 ; return(-1) ; } main() { int X[4] ; X[3] = yeoman(X) ; printf("main: %d, %d, %d\n", X[1], X[2], X[3]) ; }
#include <stdio.h> main() { int a = 1, b = 2, c = 3 ; int *ptr1, *ptr2 ; ptr1 = &a ; ptr2 = &b ; a = *ptr1 + *ptr2 ; printf("a = %d, b = %d, c = %d\n", a, b, c) ; *ptr2 = *ptr1 + c ; printf("a = %d, b = %d, c = %d\n", a, b, c) ; ptr2 = ptr1 ; printf("a = %d, b = %d, c = %d\n", a, b, c) ; *ptr2 = *ptr1 + c ; printf("a = %d, b = %d, c = %d\n", a, b, c) ; }