C++ Programming Chapters 1-3

25 July 2022
4.7 (114 reviews)
102 test answers

Unlock all answers in this set

Unlock answers (98)
question
computer
answer
an electronic device capable of performing commands (input, output, storage, arithmetic and logic operations)
question
hardware
answer
the physical components of a computer and its surrounding (peripheral) devices
question
software
answer
sets of instructions to be executed by the computer, i.e., programs
question
system software
answer
programs designed to control the computer
question
operating system
answer
a set of programs that control overall computer activity and provide services
question
Windows and Linux
answer
The two operating systems that the CS computer lab machines boot to.
question
CPU and main memory, secondary storage, input and output devices
answer
basic components of computer hardware
question
application software
answer
programs designed to perform specific tasks
question
system software and application software
answer
the two main types of software
question
editor
answer
program used to create and modify text based files
question
emacs
answer
editor used in CS labs
question
case sensitive
answer
both linux and C++ are ___________, meaning that upper case and lower case letters are different
question
ASCII
answer
collating code commonly used by computers for encoding data into sequences of bits
question
128 (numbered 0-127)
answer
the number of characters in ASCII
question
machine language, assembly language, and high-level language
answer
types of programming languages
question
machine language
answer
instructions made up of sequences of 0s and 1s
question
assembly language
answer
instructions made up of mnemonic codes
question
high-level language
answer
instructions are closer to natural language, use familiar words and symbols
question
machine language
answer
programming language that: - is the only language directly understood and executed by the computer -is machine dependent
question
assembly language
answer
programming language that: - must be translated to machine language by a program called an assembler - is machine dependent
question
high-level language
answer
programming language that: - is machine independent - must be translated by a compiler
question
BASIC, FORTRAN, Pascal, Java, C, C++
answer
Examples of high-level languages
question
compiler
answer
a program that translates instructions written in a high-level language into the equivalent machine code
question
g++
answer
the compiler used in the CS labs for C++
question
#include using namespace std; int main() { return 0; }
answer
the parts required in every C++ program
question
Program Development
answer
a problem solving process
question
Analysis, Implementation, Maintenance
answer
Three steps of Program Development
question
algorithm
answer
a step-by-step procedure for solving a problem in a finite amount of time
question
source file
answer
a human readable file that contains C++ program
question
object file
answer
executable version of program
question
program
answer
a sequence of statements whose objective is to accomplish a task
question
programming
answer
process of planning and creating a program
question
programming language
answer
a set of rules, symbols, and special words
question
syntax
answer
grammar rules of the language; compiler will try to identify and locate syntax errors
question
semantics
answer
meaning of the instructions in the language; compiler cannot find these errors - often called logic errors
question
comments
answer
nonexecutable statements that are included in a program to provide information about what the program does, how it works, what input is expected, what output is generated, who wrote it, etc.
question
preprocessor directives
answer
tells the computer where to find the library for operations and data types
question
preprocessor
answer
a program that finds and attaches to your program the indicated libraries for compilation
question
#include
answer
preprocessor directive syntax
question
using namespace std;
answer
place where identifiers used in the system provided header files are defined
question
token
answer
smallest individual unit of a programming language - special symbols, word symbols, identifiers
question
special symbols
answer
+ - * / . ; ? , < > <= >= ! != & |
question
reserved words
answer
words that are used for special purposes in a program
question
int namespace include using return
answer
examples of reserve words
question
identifiers
answer
names of things that are used in a program, can apply to variables, constants, and functions
question
whitespace
answer
characters used to separate symbols, reserved words, identifiers and statements; include blanks, tabs and newline (linefeed) characters
question
data type
answer
a set of values together with a set of operations
question
int values
answer
whole numbers, no decimals and no commas included
question
char
answer
single letters, digits, special symbols; enclose value in single quotes ('a' '?' '8')
question
escape sequences
answer
use 2 characters to represent one 'n' = newline 't' = tab
question
floating-point category: float, double
answer
data types that refer to numbers with decimals
question
Arithmetic Operators
answer
* / % + -
question
arithmetic expression
answer
a sequence of operands and operators that describe a calculation to be performed
question
operator
answer
symbol that denotes an action to be performed
question
unary operator
answer
operator with only one operand
question
binary operator
answer
operator with two operands
question
operand
answer
value, identifier, or expression that is part of the calculation to be performed
question
like-type expression
answer
an expression in which all operands have the same data type - result will have the same data type as operands
question
% modulus
answer
an operator that can only be used with int values. result will always be an int.
question
mixed expression
answer
an expression that has operands with different data types
question
type coercion
answer
when a value of one data type is implicitly (automatically) changed to another data type
question
allocating memory
answer
associate an identifier with a memory location
question
variable
answer
a memory location with a name and data type, its content may be changed during program execution
question
named constant
answer
a memory location with a name and data type and a value, its content (value) cannot be changed during program execution
question
const datatype identifier = value;
answer
syntax for named constant declaration
question
assignment statement
answer
allows the programmer to store a value in a variable
question
type casting (conversion)
answer
programmer explicitly indicates that a value is to be converted to another type
question
static_cast(expression) static_cast(total/divisor) static_cast(65)
answer
type casting syntax
question
cout
answer
a filestream variable that represents the default output device
question
<<
answer
the stream insertion operator
question
endl (same as 'n')
answer
manipulator that causes the insertion point (cursor) to move to the beginning of the next line
question
cin
answer
a filestream variable that represents the default input source
question
>>
answer
the stream extraction operator
question
prompt
answer
message displayed to the screen asking user for input; generated with an output statement
question
cmath
answer
header file that contains commonly performed mathematical functions
question
sqrt(x) expects 1 double type expression >= 0.0 as its argument
answer
square root function (give syntax and parameters)
question
pow(x,y) expects 2 double type expressions if x=0.0, y must be positive if x<=0.0, y must be a whole number returns x^y
answer
power function (give syntax and parameters)
question
manipulator
answer
used to format output
question
answer
syntax to print backslash ()
question
'
answer
syntax to print single quote
question
"
answer
syntax to print double quote
question
iomanip
answer
header file that contains commonly used manipulators used to format output
question
setw(n)
answer
used to output a value in specific # of columns
question
cout << left << ...; cout << right << ...;
answer
syntax that allows the programmer to specify whether contents of field will be left or right justified
question
setfill(ch) cout << setfill('?') << ... ;
answer
allows programmer to fill blank columns in a field with a character
question
setprecision(n) cout << fixed << showpoint << setprecision(2);
answer
controls output of floating-point numbers; give syntax
question
cout.unsetf(ios::fixed)
answer
syntax to disable the fixed manipulator
question
fixed
answer
sets floating-point values to a fixed decimal format
question
showpoint
answer
forces the computer to display decimal point and trailing zeroes
question
cin >> variable;
answer
syntax for reading char type variables by extracting one nonwhitespace character extracted at a time
question
get cin.get(ch);
answer
a function that can be used to read character data, including whitespace; give syntax
question
lpr myfile.cpp
answer
command for printing in the CS lab
question
B361
answer
room number of the computer lab
question
.cpp
answer
naming convention for C++ programs
question
a.out
answer
default name of executable file
question
ssh
answer
remote access
question
man
answer
linux command for online manual
question
cat
answer
linux command for display file
question
more -10 myprog.cpp
answer
linux command for displaying only the first 10 lines of the file
question
cat -n myprog.cpp
answer
linux command that will output the source code and will number the lines of the code.
question
ls -al
answer
linux command for listing the directory contents without ignoring system files that start with "." and listing them in long list format
question
lpr -Psage myfile
answer
linux command for printing to a printer other than the default printer.