Erin's CS stuff

CS stuff!

Topics

Tool Use Explanation C Examples
Program Basics start programming minimum syntax to create a program
(or get points in this class)
  • header comments
  • preprocessor directives
  • main function
  • return statement
Variable save stuff store values that change
(either during the program or between program runs)
  • declaration statements
  • assignment statements
  • initialization statements
Expression do stuff bit of code which results in or evaluates to another value
  • arithmetic: + - * / %
  • relational: == < <= > >=
  • logical: && ||
  • function calls
Formatted IO interact with user gets values from the keyboard or displays text to the screen
  • printf function
  • scanf function
Selection make decisions allows program to "decide" which code blocks to execute
  • if blocks
  • else blocks
  • switch statements
Iteration repetition allows program to continue executing certain blocks of code until a condition is met
  • for loops
  • while loops
  • do while loops
Arrays saving a group of stuff store a collection of same-type values that change
  • declaration (with size)
  • access a single element through the index
  • access all elements with a for loop controlled by the index
C-Style Strings saving words store a collection of chars that combine to form language
  • declared as a 1D array of chars
  • access a single element through the index
  • access all elements with a for loop controlled by the null character \0
Functions modularize code organize program into chunks of code specific enough to accomplish a single task, but generalizable enough to do it under different circumstances
  • prototypes, definitions, calls
  • returned type/value, name, parameters/arguments
Pass by Address "return" multiple values since C can only return 1 value from a function, passing the address of a variable allows it to be modified within the function
  • pointer parameters
  • address of operator &
  • dereference operator *
File IO connect to a stream and interact with a file read values from or save values to a file on the hard drive
  • FILE* data type
  • fopen and fclose functions
  • fprintf and fscanf functions
2D Arrays saving a group of stuff with multiple dimensions store a collection of same-type values that change, in rows and columns
  • declaration (with row and column sizes)
  • access a single element through the row and column indexes
  • access all elements with an outer for loop controlled by the row index and an inner for loop controlled by the column index
Arrays of Strings saving a group of words store a collection of C-style strings
  • declared as a 2D array of chars
  • access a single element through the row and column indexes
  • access all elements with an outer for loop controlled by the row index and an inner for loop controlled by the null character \0