Intro to Programming Study Guide Flashcards
(23 cards)
T/F C++ is an example of a high level language.
True
T/F C++ is an example of an interpreted language.
False
What are the semantics of a programming language?
the meaning attached to the instructions
What is the syntax of a programming language?
how instructions are written
What are the different types of identifiers?
variables and constants
Memory for variables is determined at _____ and the values are stored at ______.
compile time, run time
Memory for constants is determined at _____ time and the values are stored at _____.
compile time, compile time
What are the 3 differences in how we declare variables versus constants?
assign values to constants
declareVariables vs. DECLARE_CONSTANTS
const before declaring constants
When would we declare an identifier a constant?
when we don’t change its value, when we need to use a literal
What is a literal in C++
an actual value
What are the 2 things the compiler needs to know when we declare an identifier? How do we provide this information to the compiler?
the data type, how much memory needs to be stored
the datatype
What is the difference between ‘A’ and “A” in C++?
‘A’ - single character
“A” = C-string of 2 characters (‘A’ & ‘\0’)
How would we declare a c-string variable which could store a name of up to 10 characters?
char name[11]
How would we declare a constant named A which would store the single value ‘A’?
const char A = ‘A’
What data type would we use to store the average of a sum of integers?
float
What data type would we use to store a counter?
int
What data type would we use to store an accumulator?
int or float (depending on what I am accumulating)
What data type would we use to store a letter grade?
char
Where in a C++ program do we put the declaration section?
Immediately following int main() {
Which preprocessor directives do we need to execute the following statement:
cout «_space;fixed «_space;setprecision(2) «_space;average;
iomanip
iostream
using namespace std;
Which one do we need to use fixed?
include
Why do we need to return 0 at the end of int main()?
let the operating system know that the program is being terminated
What should we always do before using an accumulator? Why? If we don’t will it cause a compiler error?
initialize it to 0
because otherwise we will use it before assigning a value to it
no, run time error