CISC105 Fall 2006 Lab05 CISC105 Fall 2006 Lab05

Programs

  1. Write a program to demonstrate that when we pass an integer or double to a function from main(), changing the function parameter inside the function does not change the value in main.

  2. Write a program to demonstrate that when we pass an entire array to a function from main(), changing an element of the function's array parameter inside the function does change the value in main.

  3. Write a program that asks for user input (an integer), and uses a switch statement to print "obtuse" if the user enters 120 and "acute" if the user enters 42. For any other number the program should print "spam". You may only use three cases.

  4. Write a program that asks for user input (a positive integer), and uses a switch statement to print "blue" if the number is 0-3; "white" if the number is 4-7; and "emerald" if the number is 8-11. Any other number should print "mauve". You may only use four cases. Hint: use integer operations to make this simple.

  5. Use a shell command to copy the previous program. Place a do-while loop around the appropriate code so that the user is asked for data repeatedly. The program should stop when the user enters -1 (what is that number called? How should it appear in your program?).

  6. Programs 1 and 2 are crucial points to understand for the rest of the semester. Be sure you see what is happening in your code and in your results. We'll discuss this in terms of the computer's memory in class.

You should have a total of 5 programs named lab05.1.c to lab05.5.c. Make a single script file (see lab00 for the instructions) where you cat, compile, and run each one in its final form.

Submit all C files and your script on WebCT, and give the paper version of the complete script file only to your TA at the beginning of your next lab (all Friday labs) or in lecture Friday (Wednesday labs only). Note: Cat, compile, and run each program in order! Do not cat all programs, then compile, etc.



File translated from TEX by TTH, version 3.38.
On 4 Oct 2006, 02:53.