C PROGRAMMING

•A

very common programming language for applications kernel almost entirely built from C (GNU CC) common C compiler on Linux

• Linux • GCC •A

C compiler translates C code into an executable binary to run do not need to be a C programmer for this class!

• You

A SIMPLE C PROGRAM
#include <stdio.h> int main() { printf(“Hello World!\n”); return 0; } <--- hello.c

The proper file extension for a C source code file is ‘.c’

BASH SCRIPTING
• BASH • You

is your Linux terminal shell (by default)

can create BASH interpreted code to write scripts written in BASH is not compiled like C is scripts can be really handy for situations like backups the BASH file extension

• Code • BASH

• Generally, use ‘.sh’ for • Learn

more BASH scripting if you plan to use Linux a lot!

IF-THEN-ELSE
• IF

<something> THEN <something> OTHERWISE <something> common control structure for decision making in code NEST too many of these.

• Most • Don’t

if test “$word1” = “$word2” then echo “They Match!” fi ‘If ’ statements need to end with ‘fi’

Start

if Yes then
Action End Situation

No else
Action

CASE STRUCTURE
• Cleaner • Useful

to use than nesting many, many if-then-else statements

for situations with many possible ‘cases’ (as it implies...) a trivia game? Menu? Flash-card script? -- Use this!

• Creating

case $1) in “name”) echo “My name is Mark.”;; “day”) echo “Today is Wednesday.”;; *) echo “I don’t have answer, sorry.”;; esac ‘case’ statements need to end with ‘esac’

Start

Input

Apple
Action

Pear
Action End

Banana
Action

Orange
Action

FOR LOOPS
• Wait

until a list of possibilities is done before stopping when going through a list of something

• Useful • Each

loop, you will repeat the steps listed

for i in {a..z} do echo “The current letter is: $i” done ‘for’ loops need to end with ‘done’

Start

Test

No

End

Yes
Action