CSE220 Programming for Computer Engineering
Lab Project 4: 16 Points
You may work in
on this assignment if you wish or you may work
. If you work with a partner,
only hand in
assignment with both of your names on it; you will each earn the
number of points. This assign-
at 4:00am on Sun 8 March.
You are to use GNU-Linux and the GCC C compiler (
) to complete these exercises. You may use any text editor you
wish to edit the source code files, e.g., VI, Kate, Kedit, Gedit, etc. When you are done, create a directory named
and four subdirectories within this directory named
, one for each exercise. Put your
source code file(s) for each exercise in the appropriately-named subdirectory. Do not put any other files in these subdirect-
ories. Then, create a
directory using the commands,
$ tar cvf cse220-p04
assumes cse220-p04 is a subdir of your current dir
$ bzip2 cse220-p04
is your last name, and
is your first name. Upload the tarball to Moodle by the assignment submission
deadline. I configure Moodle to disable the assignment submission link at 4:00am on the due date. If you do not submit
your tarball by that time, the assignment will be considered late. Consult the online syllabus for the
Write and compile complete C programs.
Use scanf() and printf I/O functions.
Use C if statements, loops, assignment statements, operators, variable definition statements, and return statements.
Define and manipulate C-style string arrays.
Write C functions, pass parameters, return values.
C Programming Exercises
I/O in C is performed using the functions from the C Standard Library that are declared in the header file
. To use these functions, your C program must have a
statement near the top of the source
code file. We will discuss the standard I/O functions in more detail later in the lectures, but for now I want you to know
how to send integers, doubles, and strings to the stdout stream, and to be able to read integers, doubles, and strings
from the stdin stream.
To read a value from the keyboard (or stdin), use the
function which has the prototype
int scanf(char *, .
which states that scanf() returns an int, and it has one or more parameters. The first parameter is required and is a
(we will discuss the syntax char * in more detail in the lectures but for now read this as "string"). What
follows the first string parameter is a list of the variables in which the values that are read from the keyboard will be
To send a value to the console (or stdout), use the