T. Andrew Yang Email:
yang@uhcl.edu Web page
: http://sce.uhcl.edu/yang/ Tel.: (281) 283-3835 |
last updated 3/20: revisions to labs 3,
4, and 5 2/11: changes to lab 2 (demo to
the TA is required). 1/21: Labs published |
|||||
Note: An important part of problem solving is correct
understanding of the given problem. -
Try to have a good grasp of
the problem before starting the process of finding the solution(s). -
Use any resources, including
the instructor, the TA, your classmates/friends, and online resources to
ensure that you have correctly understood the given problem. -
While trying to figure out the
solution(s), continue to verify your understanding of the problem. 1.
Lab 1 Total points= 100 1.1.
(20 pts)
Visit the
class discussion group (see the syllabus for the URL) and complete the
following tasks: 1.1.1.
Configure
your membership settings, so each
email sent to the group will be forwarded to your preferred email address
(that is, the email account that you regularly check each day). 1.1.2.
Post a message with your full name as the subject line. In your
post, briefly introduce yourself (including your full name) and one item you
most desire to learn in this class. 1.1.3.
Throughout
this class, you shall regularly visit the discussion group to find recent
announcements and reminders, and to participate at discussions. 1.2. Developing
C Programs 1.2.1. Figure 1 shows a sample C program.
Figure 1.1. A sample C program
Note: The source program as shown in Figure 1.1 may
contain special characters when being saved into a text file. Fix the errors
by replacing/retyping those characters using a text editor. 1.2.2. Suppose that program is saved as a text file named test.c. Figure
1.2 is a screen snapshot that shows commands used to compile and execute that
program, using the Tiny C Compiler (tcc), and the
sample user input and the output produced by that program. Figure 1.2. Running the sample program
1.2.3. Save the sample program in Figure 1 as a text file
(with test.c as the file name).
Note: Remember where in the file system you have saved it. 1.2.4. Make the following revisions to the sample program.
Be sure to save the revised program (as test2.c). (a)
Print your own
name as the first line of that program’s screen output. (b)
Add appropriate
comments to explain the purpose/functionality of each of the statements
(comments 1 through 9). (c)
Instead of
getting two numbers from the user, the program will ask for three numbers
from the user. (d)
The result will
be number1 + number2 * number3. 1.2.5. On a computer with tcc or Microsoft Visual Studio
installed, open a command prompt to run the revised program. Note:
You are strongly encouraged to install a C compiler on your own
computer. TCC is an open-source software and free to download; visit http://download.savannah.gnu.org/releases/tinycc/
if you want to download tcc.
Note:
Not being able to install a C compiler on your own computer is NOT a
valid excuse for being late in submitting the lab.
Computers in the PC labs have Visual Studio installed and you may use them to
complete this portion of the lab.
1.2.6. To hand in: 1.2.6.1.
(40 pts) The
revised C source program per instructions above. 1.2.6.2.
(40 pts) Before
the lab is due, give the TA a face-to-face demo during his/her office hours
by showing how you’d run the revised program using one of the
computers in the lab. Note:
It is a student's responsibility to
make sure the demo is given during the TA's office hours before the due
date/time. The TA is NOT required to stay after his/her office hours in order
to see your demo. Go to the Index Total points= 100 2.1. A C program is composed of functions, each of which has a
clearly-defined functionality. A function may call other functions to perform
specific tasks. The calling relationship can be illustrated using a calling graph. 2.1.1.
Study and run the following program to understand how it
works and, in particular, how the various functions are related to each
other. Draw a calling graph to clearly show the order of function calls
and the returned value, if applicable.
2.1.2.
Revise the above program by replacing the commented-out line
(//printf("Hello. Welcome!\n My name is ...\n"); ) with a function
call greeting( ). That function
will print a simple greeting message followed by introducing your own name.
For example, when the greeting( ) function
is called, it may display the following greeting message on the screen:
Hello. Welcome!
My name is John Doe. (Note:
Use your real name.) To hand in: 2.1.2.1.
(30 pts) The calling graph
from 3.1.1 above. 2.1.2.2.
( 2.1.2.3.
(30 pts) Before the lab is due, give the TA a
face-to-face demo during his/her office hours by showing how you’d run
the revised program using one of the computers in the lab. Go to the Index Total points= 100 3.1. Write a program that
asks the user to continue to enter two numbers (at a time). For each pair of
numbers entered, the program calculates the product of those two numbers, and
then accumulate that product. For each pair of numbers entered, the program
also prints the entered numbers, their product, and the accumulated products.
The process will continue until the user enters two zeros. See the following
screen snapshot for a sample running of the completed program. NOTE: Use a do … while loop. Requirements:
Write your program such
that it generates screen output as shown above. 3.1.1.
(30 pts) Write a pseudocode to
show the logic of your program. 3.1.2. (70 pts) The source program with
proper comments.
Go
to the Index Total points= 100 4.1. The following is a
partially completed program that continues to (a) first display a menu of
commands, and then (b) asks the user to choose 1 to enter a grade or 0 to
quit the input process. Your job is to complete the main( ) function by
implementing a for loop.
Requirements:
4.1.1.
(30 pts) Write a pseudocode to
show the logic of the main( ) function. 4.1.2. (70 pts) The source program with
proper comments.
Go
to the Index Total points= 100 5.1. The following is a
partially completed program that displays the content of an integer array,
and then displays the average value of all numbers in that array. Your job is
to complete the program by adding the definition of the function arrayAverage( ).
5.2.
Requirements: Write your program such that it
generates screen output as shown above. 5.2.1. (30 pts) Draw a flowchart
to show the logic of the arrayAverage( ) function. 5.2.2. (70 pts) The source program with
proper comments.
Go
to the Index |