Syntax Structures Flashcards

1
Q

Syntax Structures

A

pattern of symbols that make up a code form

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

Code form

A

the form of an

if-statement or a while-loop

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

How to read these code forms

A
  1. Anything in ALLCAPS is meant as a replacement spot or hole.
  2. Seeing [ALLCAPS] means that part is optional.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

if-statement

A

basic logic branching control

if(TEST) {
CODE;
} else if(TEST) {
CODE;
} else {
CODE;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

switch-statement

A

like an if-statement but works on simple integer constants

switch (OPERAND) {
case CONSTANT:
CODE;
break;default:
CODE;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

while-loop

A

your most basic loop

while(TEST) {
CODE;
}

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

while-continue-loop

A
while(TEST) {
if(OTHER_TEST) {
continue;
}
CODE;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

while-break-loop

A

use break to exit a loop

while(TEST) {
if(OTHER_TEST) {
break;
}
CODE;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

do-while-loop

A

an inverted version of a while-loop
runs the code
then tests to see if it should run again

do {
CODE;
} while(TEST);

Can have continue and break inside to control how it operates

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

for-loop

A

controlled counted loop through a fixed number of iterations using a counter

for(INIT; TEST; POST) {
CODE;
}

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

enum

A

enum { CONST1, CONST2, CONST3 } NAME;

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

goto loop

A

A goto will jump to a label
Used for error detection and exiting

if(ERROR_TEST) {
goto fail;
}

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

Define a function

A
TYPE NAME(ARG1, ARG2, ..) {
CODE;
return VALUE;
} 

or

int name(arg1, arg2) {
CODE;
return 0;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

typedef

A

defines a new type

typedef DEFINITION IDENTIFIER;

or

typedef unsigned char byte;

Don’t let the spaces fool you; the DEFINITION is unsigned char and the IDENTIFIER is
byte in that example.

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

struct

A

A struct is a packaging of many base data types into a single concept

struct NAME {
ELEMENTS;
} [VARIABLE_NAME];

The [VARIABLE_NAME] is optional

or

typedef struct [STRUCT_NAME] {
ELEMENTS;
} IDENTIFIER;

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

union

A

union creates something like a struct, but the elements will overlap in memory

union NAME {
ELEMENTS;
} [VARIABLE_NAME];