Deck 1: C++ Basics

Full screen (f)
exit full mode
Question
C++ uses only /* */ for comments.
Use Space or
up arrow
down arrow
to flip the card.
Question
A program should have a comment on every line.
Question
The most difficult programming language construct to learn to use properly is the comment.
Question
To put a character into a cstring constant that causes the output to continue on the next line,insert the escape sequence \t into the string constant.
Question
In C++ you can assign an expression of type double to a variable of type int with no problem.
Question
A computer program is a set of instructions intended for only the computer to follow.
Question
C++ not only supports OOP but also supports other programming styles.
Question
A program's comments should connect the program code to the problem being solved.
Question
The names x,y,and z are satisfactory variable names for the lengths of the legs and hypotenuse of a triangle.
Question
If we execute this code in an otherwise correct and complete program:
n = 1;
n = (n++)+ (n++);
the value of n is guaranteed to be 3 after the second line executes.
Question
In C++ the variables Alpha,ALPHA and AlphA are the same identifier.
Question
The namespace facility is a tool used that assists in the study of genealogy.
Question
OOP is an acronym that means Object Oriented Programming.
Question
In C++ the compiler will infer the type intended for a variable from the context in which the variable occurs.
Question
Comments have no value whatsoever and do not belong in a program.
Question
In C++ you can assign an expression of type int to a variable of type double with no problem.
Question
A C++ declaration is a definition that also allocates storage for an identifier's value (or function's body etc. ).
Question
The range of values for an int variable is from about 0 to +2 billion.
Question
If we execute the code fragment in an otherwise complete,correct program:
n = 1;
cout << n++ << " " << n++ << " " << n++ << endl;
the output is guaranteed to be 1 2 3.
Question
A C++ declaration introduces only an identifier's spelling and specifies its type.
Question
When you use a double,what is doubled? When you use a long int,how much longer is the long int than an int? Comment.
Question
Give the declaration for two variables,feet and inches.Declare each to be of type int,and both initialized to zero in the declaration.Give both initialization alternatives.
Question
In C++,a legal identifiers may contain these kinds of characters _______________,______________,______________
Question
Which of the following are likely to be poor choices for an identifier in a program? Why?
a)x
b)RATE
c)data
d)_abc
e)A
Question
Which of the following will properly encode the string "\w\\\t" into variable s?

A)s = "\w\\\t";
B)s = R"(\w\\\t)";
C)s = "\\w\\\\\\t";
D)s = "/w///t";
Question
What is the value assigned to the variable in each of these cases? Explain curious results.Be careful!
int x,y;
a)x = 1/2;
b)y = 3.0/2.0;
double z,w,t;
c)z = 1/2;
d)w = 3/2;
e)t = 3.0/2.0;
Question
An r-value is

A)an expression that can be only placed on the right of any operator such as +,*,/ etc.
B)can never be assigned a value
C)can have a value fetched from it
D)is designed for use by a right-handed person.
Question
Write a C++ program that outputs "My first C++ program" and then outputs a carriage return.
Question
What is the data type of variable x in the following C++11 code: int y= 2;
Double z = 3.5;
Auto x = z * y;

A)int
B)double
C)auto
D)syntax error
Question
Given the C++ output statements.What is the output of these lines of code? Explain.
cout << "If you have ";
cout << "a number of pods ";
cout << "you can quit.";
cout << "\n";
Question
What is the difference between a warning from the compiler and an error message from the compiler?
Question
What does the line
#include
do for your program?
Question
Identifiers should at least give a hint to the human reader of the ________________ of the identifier in the context of the problem being solved.
Question
In the history of the C++ language,what was the immediate predecessor of the C++ language? How is this older language related to C++?
Question
Write a short program that contains statements to output the values of a variable that you define but neither initialize nor assign.Discuss the output you get.
Question
The C++ very nearly contains the ______ programming language as proper subset.
Question
With C++11 and higher what data type can you use to guarantee that 32 bits will be used to store a signed integer?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/37
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 1: C++ Basics
1
C++ uses only /* */ for comments.
False
2
A program should have a comment on every line.
False
3
The most difficult programming language construct to learn to use properly is the comment.
True
4
To put a character into a cstring constant that causes the output to continue on the next line,insert the escape sequence \t into the string constant.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
5
In C++ you can assign an expression of type double to a variable of type int with no problem.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
6
A computer program is a set of instructions intended for only the computer to follow.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
7
C++ not only supports OOP but also supports other programming styles.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
8
A program's comments should connect the program code to the problem being solved.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
9
The names x,y,and z are satisfactory variable names for the lengths of the legs and hypotenuse of a triangle.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
10
If we execute this code in an otherwise correct and complete program:
n = 1;
n = (n++)+ (n++);
the value of n is guaranteed to be 3 after the second line executes.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
11
In C++ the variables Alpha,ALPHA and AlphA are the same identifier.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
12
The namespace facility is a tool used that assists in the study of genealogy.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
13
OOP is an acronym that means Object Oriented Programming.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
14
In C++ the compiler will infer the type intended for a variable from the context in which the variable occurs.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
15
Comments have no value whatsoever and do not belong in a program.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
16
In C++ you can assign an expression of type int to a variable of type double with no problem.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
17
A C++ declaration is a definition that also allocates storage for an identifier's value (or function's body etc. ).
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
18
The range of values for an int variable is from about 0 to +2 billion.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
19
If we execute the code fragment in an otherwise complete,correct program:
n = 1;
cout << n++ << " " << n++ << " " << n++ << endl;
the output is guaranteed to be 1 2 3.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
20
A C++ declaration introduces only an identifier's spelling and specifies its type.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
21
When you use a double,what is doubled? When you use a long int,how much longer is the long int than an int? Comment.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
22
Give the declaration for two variables,feet and inches.Declare each to be of type int,and both initialized to zero in the declaration.Give both initialization alternatives.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
23
In C++,a legal identifiers may contain these kinds of characters _______________,______________,______________
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following are likely to be poor choices for an identifier in a program? Why?
a)x
b)RATE
c)data
d)_abc
e)A
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following will properly encode the string "\w\\\t" into variable s?

A)s = "\w\\\t";
B)s = R"(\w\\\t)";
C)s = "\\w\\\\\\t";
D)s = "/w///t";
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
26
What is the value assigned to the variable in each of these cases? Explain curious results.Be careful!
int x,y;
a)x = 1/2;
b)y = 3.0/2.0;
double z,w,t;
c)z = 1/2;
d)w = 3/2;
e)t = 3.0/2.0;
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
27
An r-value is

A)an expression that can be only placed on the right of any operator such as +,*,/ etc.
B)can never be assigned a value
C)can have a value fetched from it
D)is designed for use by a right-handed person.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
28
Write a C++ program that outputs "My first C++ program" and then outputs a carriage return.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
29
What is the data type of variable x in the following C++11 code: int y= 2;
Double z = 3.5;
Auto x = z * y;

A)int
B)double
C)auto
D)syntax error
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
30
Given the C++ output statements.What is the output of these lines of code? Explain.
cout << "If you have ";
cout << "a number of pods ";
cout << "you can quit.";
cout << "\n";
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
31
What is the difference between a warning from the compiler and an error message from the compiler?
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
32
What does the line
#include
do for your program?
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
33
Identifiers should at least give a hint to the human reader of the ________________ of the identifier in the context of the problem being solved.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
34
In the history of the C++ language,what was the immediate predecessor of the C++ language? How is this older language related to C++?
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
35
Write a short program that contains statements to output the values of a variable that you define but neither initialize nor assign.Discuss the output you get.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
36
The C++ very nearly contains the ______ programming language as proper subset.
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
37
With C++11 and higher what data type can you use to guarantee that 32 bits will be used to store a signed integer?
Unlock Deck
Unlock for access to all 37 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 37 flashcards in this deck.