CISC105 Fall 2006 Lab05
CISC105 Fall 2006 Lab05
- Write a program for each of the following problems. Be sure to
save every separate program. All programs must be properly commented
and indented (see Assignment Standards on the class website).
- CODE! If you are having difficulty writing programs,
consider programming more often. Working on C every day makes a big
difference, and leaving it alone, even just for a weekend, can
result in backsliding. You are learning a language and a way of thinking.
- Every function gets commented with a brief description. Discuss
this with your TA to learn what is appropriate.
- Name each program lab05.n.c, where n is the number in the list
below. For example, the name of the file for the first will be
lab05.1.c. Put the files in your lab05 directory.
Programs
-
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.
-
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.
-
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.
- 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.
-
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?).
- 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.