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

  1. Name the six basic C data types and demonstrate how to declare variables of each type.
  2. Write assignment statements in the form of var = value;
  3. Perform mathematical calculations using the appropriate operators for addition (+), subtraction (-), multiplication (*), division (/), and modulo (%). Use parentheses to control operator precedence.
  4. Write conditional statements using if and else. This includes statements with multiple conditions using the AND (&&) and OR (||) operators.
  5. Write loop constructs using the three loop operators: for, while, and do...while.
  6. Write conditional statements using switch.
  7. 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.
  8. Perform basic keyboard input operations using using the C++ iostream function cin >>.
  9. Perform basic output (print to screen) operations using printf() including printing data from any of the six basic C data types.
  10. 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.
  11. Declare arrays of any of the six basic data types. Insert and access data in the arrays.
  12. Perform simple string manipulation operations: declare arrays of characters to use as strings, use the string functions strcpy(), strcmp(), and strlen().
  13. Perform simple file I/O operations on text files using the functions fopen(), fputs(), fgets(), and fclose.
  14. 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

  1. Starting up Visual C++ and beginning a new console project.
  2. Add a new source file to a project.
  3. Remove a source file from a project.
  4. Compile and run a project.
For additional information on using Visual C++ click here.

Additional programming concepts

  1. What is a source file in C?
  2. What is a header file and how is it used.
  3. What is an executible file?

Self Test

Test your programming skills by writing a program, using Visual C++, to do each of the following.
  1. 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.
  2. 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.
  3. 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.
  4. 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.