COSC-1337 Chapter 4 Flashcards

1
Q

What is a semi-colon used for in C++?

A

A semi-colon is used ONLY after you have written a complete statement.

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

What happens if you accidentally put a semi-colon after the “if (condition)”?

A

The semi-colon will become a “null terminator” and the statements in the block following the “if statement” will execute regardless of wether or not the conditions are met.

A “null terminator” is considered a blank statement in C++ that does nothing. This would result in terminating the “if statement” early.

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

When a message is printed to let the user know that they have entered in invalid input, what is this called?

A

Input validation

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

What is “is alpha()” used for?

A

To test whether or not a variable or input is a alphabetic character

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

Variables that are defined inside the set of braces are known to have a?

A

Local scope or Block scope

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

What does a conditional operator look like?

A

x >= 0 ? y = 1 : z = 25;

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

What type of operator is a conditional operator known as?

A

Ternary operator. This is because it has three operands.

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

Does a switch structure recognize both upper case and lower case letters?

A

Yes.

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

How do we create a data type named “Names” and assign the values of 22, 55, and 205 to the variables Tim, Jim, Pam?

A

enum Names {Tim = 22, Jim = 55, Pam = 205};

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

What file header do you need to use with things like isalpha();?

A

cctype header file

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