Identifiers Flashcards

1
Q

In C++ there are 6 basic containers

A

(int, float, double,

char, string, and boolean)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

int (Integer)

A

used to store whole numbers, positive

and negative, including zero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

float and double

A

used to store decimal numbers, positive

and negative.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

char (character)

A

used to store a “single” letter, number,

symbol, or space. [All char types use ‘’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

string

A

used to store “zero or more” letters, numbers,

symbols, or spaces. [All string types use “”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

bool (boolean)

A

used to hold boolean logic, which can contain

a value of 0 or 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Declaring (creating) variables and constants (Three steps)

A

a) Choose the data type (or container)
b) Choose the indentifier name (label it)
c) Initialize the value (Required for constants)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

c) Initialize the value (Required for constants

A
  1. numerical values - initialize with a 0

2. non-numerical values - initialize with a empty string or char

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ex identifiers

A
int age = 0;
	   string bldgName = " ";
	   char middle_Initial = ' ';
	   bool isActive = 0;
	   float gpa = 0;
	   const double PI = 3.14;
	   const int DAYS_OF_THE_WEEK = 7;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Naming convention for indentifiers

A

a) If it is defined as a const type, use ALL-CAPS for the name
b) For multi-word names, either use camel-case or underscores
c) Always start with a letter
d) After the first letter of the name, you can use letters,
numbers, and underscores.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Assigning values to variables

A

a) The assignment operator “=” is used to assign values

b) The right-hand side is assigned to the left (LHS = RHS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Other notes

A

a) You can’t use a variable unless you DECLARE IT FIRST.
b) When you give a variable or constant a name, it is bound
by that EXACT name. (C++ is CaSe SeNsItIvE)

	  ex.  int age = 0; AND int aGe = 0;  (Different variables)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

[Ex.] Declare identifiers

Re-assign variables

A
int age = 0;
	string bldgName = " ";
	char middle_Initial = ' ';
	bool isActive = 0;
	float gpa = 0;
	const double PI = 3.14;
	const int DAYS_OF_THE_WEEK = 7;
 int num1 = 10000;
   int num2 = 20;
   string name = "William";
   char grade = 'A';
   bool isGraduating = 1;
   float gpa = 3.2;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly