CS 221
Knowledge Prerequisites
Below is a list of programming skills and concepts you should have mastered
in your introductory programming course. These are things which are
absolutely essential for success in this class. You should go through the
list and make sure you understand everything. A review of basic C programming
is available through the "Basics" link on the main page.
Basic C Programming
-
Name the six basic C data types and demonstrate how to declare variables
of each type.
-
Write assignment statements in the form of var = value;
-
Perform mathematical calculations using the appropriate operators for
addition (+), subtraction (-), multiplication (*), division (/), and
modulo (%). Use parentheses to control operator precedence.
-
Write conditional statements using if and else. This
includes statements with multiple conditions using the AND (&&) and
OR (||) operators.
-
Write loop constructs using the three loop operators: for, while,
and do...while.
-
Write conditional statements using switch.
-
Perform basic keyboard input operations using using the C function scanf(). This should
include using the appropriate format specifiers (%d, %ld, %f, %lf, %c, %s) in order
to input data for any of the six basic C data types.
-
Perform basic keyboard input operations using using the C++ iostream function cin >>.
-
Perform basic output (print to screen) operations using printf() including
printing data from any of the six basic C data types.
-
Perform basic output (print to screen) operations using the C++ iostream
function cout << including
printing data from any of the six basic C data types.
-
Declare arrays of any of the six basic data types. Insert and access data in the
arrays.
-
Perform simple string manipulation operations: declare arrays of characters to use
as strings, use the string functions strcpy(), strcmp(), and strlen().
-
Perform simple file I/O operations on text files using the functions fopen(), fputs(),
fgets(), and fclose.
-
Write functions to be called by other functions in a program. You should be able
to write functions which take several arguments and return a value.
Visual C++ Compiler Use
-
Starting up Visual C++ and beginning a new console project.
-
Add a new source file to a project.
-
Remove a source file from a project.
-
Compile and run a project.
For additional information on using Visual C++ click
here.
Additional programming concepts
-
What is a source file in C?
-
What is a header file and how is it used.
-
What is an executible file?
Self Test
Test your programming skills by writing a program, using
Visual C++, to do each of the following.
-
Input an integer from the user between 5 and 25. Repeatedly print some
simple text string the number of times as indicated by the user. Do the
printing three times: once in a loop controlled by a for statement,
once by a while statement, and once by a do...while loop.
Click here for sample source code.
-
Create four variables: an integer, a long, a float, and a double. Write four
functions each of which returns one of these data types. Call each function and
store the returned value in the appropriate variable. Finally print the values.
Create this program so that main() is in one source code file and the four functions
are in a separate source code file.
Click here for sample source code.
-
Input an integer from the user between 0 and 100. Using if statements
print a message to the user indicating if the number is less than 25, from
25 to 49, from 50 to 74, or 75 to 100.
Click here for sample source code.
-
Create an array of 10 integers. Input a number between 1 and 25 from the user.
Using a for loop store the number input by the user times the index of each
element in the array into that element, e.g. if the user inputs
5 store the values 0, 5, 10, 15, 20...etc. in the array at index 0, 1, 2, 3, 4...etc.
Finally, print all the values stored
in the array using a while loop.
Click here for sample source code.