36 Questions
Code should be ______ but not so short that it is cryptic
concise
Identifiers should accurately describe the data being ______
stored
The first letter of each word in camelNotation is capitalized, with the exception of the ______ word
first
Reserved words are used for the ______ own use
language's
C++ reserved words include ______, namespace, and template
asm
Identifiers should avoid using ______ characters
underscore
The contents of this document are copyrighted by ______ and Seneca College
Chris Szalwinski
This document is part of the introduction to ______
C
Since characters and symbols have no intrinsic ______ representation, the host platform provides the collating sequence for associating each character and symbol with a unique integer value.
binary
______ is more popular and represents the letter A by the bit pattern 010000012, that is the hexadecimal value 0x41, that is the decimal value 65.
ASCII
______ and ______ are not compatible.
ASCII; EBCDIC
Neither ______ nor ______ contain enough values to represent most of the characters and symbols in the world languages.
ASCII; EBCDIC
A ______ programming language uses a type system to interpret the bit streams in memory.
typed
The Unicode standard, which is compatible with ______, provides a much more comprehensive collating system.
ASCII
There are three schemes for storing negative integers: ______ notation (most popular), 1's complement notation, and sign magnitude notation.
2's complement
A ______ is the rule that defines how to store values in memory and which operations are admissible on those values.
type
A ______ occupies one byte and can store a small integer value, a single character or a single symbol.
char
An ______ occupies one word and can store an integer value.
int
The four most common types in the C language for performing arithmetic calculations are ______, int, float, and double.
char
This chapter describes the four most common ______ in the C language and the ranges of values that these types allow.
types
After reading this section, you will be able to select appropriate ______ for storing program variables and constants.
types
This chapter concludes by describing how to allocate memory for variables by identifying their contents using a ______.
type
To obtain the 2's complement of an integer, we ______ the bits and add one
flip
The IEEE 754 standard is used for ______ and Floating-Point Arithmetic
Binary
A float has ______ bits, consisting of one sign bit, an 8-bit exponent and a 23-bit significand
32
A double occupies ______ bits, has one sign bit, an 11-bit exponent and a 52-bit significand
64
The number of bits in the significand is limited, so the ______ and double types cannot store all possible floating-point values exactly
float
The number of bytes allocated for a type determines the ______ of values that that type can store
range
Ranges for some types depend on the ______ environment:
execution
The type ______ has a size of 8 bits:
char
The ______ type has a minimum size of 16 bits:
short
The limits on a ______ and double depend on the execution environment:
float
We store program data in ______:
variables
A declaration associates a program ______ with a type:
variable
The type of a variable identifies its ______ properties:
data
The limits on the ______ are in base 10:
exponent
Study Notes
Naming Conventions
- Use descriptive and concise names that do not require comments to describe their purpose
- Use "camelNotation" (first letter of each word capitalized except the first word)
- Avoid underscore characters to avoid conflicts with system libraries
Reserved Words
- The C language reserves specific words for its own use, including:
- auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, inline, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while
- Avoid using C++ reserved words, including:
- asm, bool, catch, class, const_cast, delete, dynamic_cast, explicit, export, false, friend, mutable, namespace, new, operator, private, protected, public, reinterpret_cast, static_cast, template, this, throw, typeid, typename, using, virtual, wchar_t
Introduction to C
- C is a typed programming language that uses a type system to interpret bit streams in memory
- A type defines how to store values in memory and which operations are admissible on those values
- The relation between types and raw memory is illustrated in the figure below
Types
- Four most common types in C are:
- char
- int
- float
- double
Arithmetic Types
- char:
- Occupies one byte
- Can store a small integer value, a single character, or a single symbol
- int:
- Occupies one word
- Can store an integer value
Negative Values
- Three schemes for storing negative integers:
- 2's complement notation (most popular)
- 1's complement notation
- Sign magnitude notation
- To obtain the 2's complement of an integer:
- Flip the bits
- Add one
Floating-Point Data
- Floating-point types store tiny and huge values by decomposing values into three components:
- Sign
- Exponent
- Significand (or mantissa)
- IEEE 754 Standard for Binary and Floating-Point Arithmetic is the most popular model
- float:
- 32 bits
- One sign bit, 8-bit exponent, and 23-bit significand (or mantissa)
- double:
- 64 bits
- One sign bit, 11-bit exponent, and 52-bit significand (or mantissa)
Value Ranges
- The number of bytes allocated for a type determines the range of values that that type can store
- Ranges for some types depend on the execution environment
- Integral types:
- char: -128 to 127 or 0 to 255
- short: -32,768 to 32,767
- int: -32,768 to 32,767 (2 bytes) or -2,147,483,648 to 2,147,483,647 (4 bytes)
- long: -2,147,483,648 to 2,147,483,647 (4 bytes) or -9,233,372,036,854,775,808 to 9,233,372,036,854,775,807 (8 bytes)
- Floating-point types:
- float: depends on the execution environment
- double: depends on the execution environment
Variable Declarations
- A declaration associates a program variable with a type
- The type identifies the properties of the variable
This quiz explores how C language associates characters and symbols with unique integer values using collating sequences such as ASCII and EBCDIC.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free