Assignment 1: Getting Started
Assignment 1: Getting Started
Assignment 1: Getting Started
C/C++ Programming I
General Information
Getting Started
Before starting your first assignment you must have the appropriate tools for developing your software,
and the best way to get them is to download and install one of the many free integrated development
environment (IDE) packages. These integrate the compiler, editor, and other necessary tools into a
convenient GUI application. Although you are free to use any tools you wish and any operating system
that will support them, I recommend Microsoft’s "Visual Studio Community" for Windows, "Xcode" for Max
OS X, and "Code::Blocks" for Linux. Information on obtaining, installing, and using them is available in the
appropriate version of the course document titled "Using the Compiler's IDE…", a link to which is located
on the "Assignments" page of the course Web site. I’m sorry but I don’t have information on other IDE’s
or operating systems.
Although some of the following terminology has not yet been discussed in this course it is placed here
for completeness and for future reference: Header files typically contain things like macro definitions,
inline function definitions, function prototypes, referencing declarations, typedefs, class/structure/union
descriptions, and templates, although any of these that will only ever be needed by one specific
implementation file may be placed in that file instead. Header files must not contain non-inline function
definitions or defining variable declarations; these must be placed in implementation files instead. The
header files that are supplied with a compiler provide the information it needs to properly compile code
that uses the various functions, macros, and data types available in the compiler’s libraries.
Too Easy?
If, after completing the three exercises in this document, you would like to gain more programming
experience please contact the instructor at [email protected] and request a
supplemental set of Assignment 1 exercises. Note, however, that these are only for your own benefit
and you will not receive any extra credit for doing them.
1. Which of the following is not a character 4. What data types are acceptable for x in the
literal? expression printf("%d", x)
(Note 1.5) (Note 1.11)
A. 'A' A. int only
B. 1 double quote between 2 single quotes B. int and double only
C. '\0' C. char, short, and int only
D. '\x5' D. char, short, int, and long only
E. 1 single quote between 2 single quotes E. any of the above
2. Which of the following is not a string literal? 5. What data types are acceptable for x in the
(Note 1.5) expression scanf("%d", &x)
A. nothing between 2 double quotes (Note 1.13)
B. spaces between 2 double quotes A. int only
C. 1 single quote between 2 double quotes B. int and double only
D. 1 double quote between 2 double C. char, short, and int only
quotes D. char, short, int, and long only
E. \t between 2 double quotes E. any of the above
3. Assuming the ASCII character set, predict 6. For the declaration char ch; expressions that
the output from: will input a character from the user into the
printf("\x49\146\155\155\x70\x0021"); variable ch, skipping all leading whitespace
(Note 1.5 & Note B.1 ASCII Code Chart) are:
A. nothing - The compiler will not allow this. (Note 1.15)
B. \x49\146\155\155\x70\x0021 A. scanf("%c", &ch) and cin >> ch
C. \xe\1)( B. ch = getchar() and cin.get()
D. Ifmmp! C. scanf("%c", &ch) and cin >> &ch
E. none of the above D. scanf("\n%c", &ch) and cin >> ch
E. scanf("%c", ch) and cin >> (char)&ch