ESP - Week 4 Flashcards
bool Datatype cast
i = int(true/false) i = 1 or 0
Constant syntax
const int int_name = number;
Static declarations
Keeps the value of a variable inside a loop without needing global scope
Defining new types
struct {
datatype type_name;
} structure_name;
enum syntax
enum {x, y, z} enum_name
Making a pointer
int *x;
What is the significance of int b[10];
b reserves space for 10 integers and points b at the first one (the zeroth)
What is the significance of char *h = “hello”;
h reserves space for 5 characters (h,e,l,l,o) and a zero and points a at the first
What is the significance of int l [] = {1,2,3,4,5};
l reserves space for 5 integers and points l at the first
type of l is also int *
What is the syntax for pointer arithmetic
int *list = {1,2,3,4,5}
int *a;
a = list;
Computational Models
Sequential - A set of statements
Communicating - Multiple sequence programs
OOP - Breaks complex software into simple pieces
Finite State - For control dominated systems
What is the purpose of a static data type
It is remembered forever
If a button used to be pressed and is not pressed now what has happened
It has just been released
How to get a bool value if a variable is defined
ifdef
From FSM to code (1)
enum all states
declare state variables
initialize
declare functions
From FSM to code (2)
single switch statement
each case handles actions of state
each case checks condition and sets next state
Flowchart model
Terminals: Round
Operations: Rectangle
Decision: Diamond
Input/Output: Parallelogram
Designing system
Design system first then implement it