You are on page 1of 3

C Skills Assessment

The University of Washington


James K. Peckol

The C++ language was developed by Bjorn Stroustrop as a means by which he could incorporate
objects and the object centered paradigm into C, a procedural language. Because it is built on
and utilizes many aspects of C, the study of C++ requires knowledge of and facility with much
of the underlying language. Such knowledge includes:
1. Variables and variable types.
2. Pointers, pointer types, and their values.
3. Program structure.
4. Basic data structures such as the array and struct.
5. Functions and passing data or pointers to data into a function.
6. Flow of control such as branching and looping.
7. Program Input and Output.
Such knowledge of C can be acquired in a variety of ways including self-study, taking courses in
the C language, or taking a C++ course that incorporates the C background material.
The following thirteen projects are written to assess basic knowledge of each of the core aspects
of the C language listed above that are considered essential to the successful study of the C++
language. Completion of the thirteen projects should take less that one hour.
C Skills Assessment Projects

Variables and Pointer Variables


1. Declare, define, and initialize three variables, one of type int, one of type float, and one
of type char. Initialize the int to 5, the float to 2.147, and the char to ‘e’.
Print the three values to the display.

2. Declare, define, and initialize three variables, one of type int, one of type float, and one
of type char. Initialize the int to 5, the float to 2.147, and the char to ‘e’.
Declare, define, and initialize three pointers, one to each of the variables.
Print the three values, through the three pointers, to the display.

Arrays
3. Declare, define, and initialize a 5 element integer array to the values 1, 1, 2, 3, 5. Print
the value of the entry at each index of the array to the display. Do not use any iteration
constructs.

4. Declare, define, and initialize a 5 element integer array to the values 1, 1, 2, 3, 5.


Declare and define a pointer to the array. Print the contents of the array to the display
using the pointer. Do not use any looping constructs.

5. Declare, define, and initialize a 5 element integer array to the values 1, 1, 2, 3, 5.


Declare and define a pointer to the array. Using the pointer, interchange the elements of
the array such that its contents are 5, 3, 2, 1, 1. Print the contents of the array to the
display using the pointer. Do not use any looping constructs.

Structs
6. Declare and define a struct that contains three variables, one of type int, one of type float,
and one of type char. Assign the value 5 to the int, 2.147 to the float, and ‘e’ to the char.
Print the three values to the display.

Functions, Parameters, and Flow of Control


7. Declare, define, and initialize three variables, one of type int, one of type float, and one
of type char. Initialize the int to 5, the float to 2.147, and the char to ‘e’.
Declare, define, and initialize three pointers, one to each of the variables.
Declare and define a function, printData, that takes pointers such as those defined above
as arguments and that will print the values of each of the arguments to the display.
Invoke the function, from the main routine, with the three pointers above as parameters.
8. Declare, define, and initialize a 5 element integer array to the values 1, 1, 2, 3, 5.
Declare and define a pointer to the array. Using the pointer, interchange the elements of
the array such that its contents are 5, 3, 2, 1, 1. Do not use any looping constructs.
In the main routine, pass the array into a function, printArray, by pointer. In the
function, using a for loop, print the value of each element in the array to the display.

9. Declare and define a struct that contains three variables, one of type int, one of type float,
and one of type char. Assign the value 5 to the int, 2.147 to the float, and ‘e’ to the char.
Pass the struct into a function, printStruct, by pointer. In the function, print the value of
each element in the struct to the display.

Program Structure
10. Decompose the solution in question 7 into a multiple file program. Let one file contain
the main routine, a second contain the function implementation, and a third contain the
header information. Execute the program.

Basic I/O

11. Prompt the user to enter his or her given name followed by their family name. Accept,
then print the user’s given and family names to the display.

12. Prompt the user to enter a number between 0 and 100. If the user’s number is greater
than 50, print the word big to the display otherwise print the word small.

13. Declare and define a 5 element array. Using a for loop, prompt the user to enter 5
integers, one at a time; enter each into the array. After the last element is entered, exit
the for loop. Using a second for loop, print the contents of the array to the display.

You might also like