文档介绍:Lab 7 Pointers OBJECTIVES pleting this experiment, you will be able to: ? Understand p ointers fundamentals ? Understand f unctions and pointers ?P ass arrays to functions ? Use p ointers to One-Dimensional Arrays PROCEDURES 1. What format speci ? ers (in order) should be used in the printf() statement in the following program? Note that in the program the correct format speci ? ers have been replaced by Z. #include <> int main(void) { intx= 5; int *x_ptr = &x; printf("%Z, %Z, %Z, %Z\n", x, *x_ptr, &x, x_ptr); } Your answers : (2 Marks) %d,%d,%p,%p —————————————————— Print Screen of Result: (3 Marks) 2. On a machine in which addresses are 2 bytes, what is printed by the following program: #include <> int main(void) char fun[] = "Programming is fun."; char favorite[] = "My favorite class is programming."; char *x= fun; printf("%d\n", sizeof(fun)); printf("%d\n", sizeof(favorite)); printf("%d\n", sizeof(x)); } Your answers : (2 Marks) 20342 —————————————————— Print Screen of Result: (3 Marks) 3. Rewrite the following program, replacing the subscript (index) notation with the corresponding pointer notation. Only change the parts of the program necessary for the replacement. #include <> int main(void) { int data[] = {1, 2,3,4,5, 6}; int i; for(i =0;i<6; i++) printf("%2d", data[i]); } Print Screen of Code: (6 Marks) —————————————————— Print Screen of Result: (3