Syntax Flashcards

1
Q

How do you add a comment to your code?

A

With ‘//’ you can add a comment

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

Where must an escape sequence be located?

A

Within the double quote of a string

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

How do you add a block comment to your code?

A

With ‘/*’ and a closing */ you can add a block comment

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

What are some rules to variable naming?

A
  1. Names can include upper or lower case letters, numbers, and underscores
  2. The first character must be a letter
  3. No keywords are allowed as the full name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the ‘int’ variable type hold?

A

Whole numbers from -2.1 billion to 2.1 billion

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

What does the ‘float’ variable type hold?

A

Numbers with possible decimal value (up to 6 decimal places)

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

What does the ‘double’ variable type hold?

A

Numbers with possible decimal value (up to 15 decimal places)

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

What does the ‘char’ variable type hold?

A

One letter or number

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

In printf double quotes what does %d and %i display?

A

Integers

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

In printf double quotes what does %f display?

A

Double or Float

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

In printf double quotes what does %c display?

A

Character

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

In printf double quotes what does \n cause?

A

A newline

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

In printf double quotes what does \r cause?

A

A carriage return

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

In printf double quotes what does \t cause?

A

A tab

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

What does a character need around it if you are declaring the value of a variable on the same line?

A

Single quotes: ‘a’

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

What is more accurate a float or double?

A

Double

16
Q

When can variables be declared?

A

On the same line as they are named or any future point in the code

17
Q

How do you create a constant?

A

Before the data type, add ‘const’ and be sure to set the name of your constant to be all upper case. (Best practice)