The Beginning
Let's take 5 mins to introduce yourself to your neighbours (physical or virtual)
Feeling unwell? Need to travel back home for an emergency? Dog ate your assignment?
Producing a set of instructions and/or data to achieve a task
An Operating System is the interface between the user and the computer hardware
Operating Systems:
Terminal handles user input, rendering shell output
The shell, (bash, zsh) is a program that executes commands, and has its own syntax. It returns output which the terminal can display
The prompt is controlled by the shell, and is the line of text which displays some information
ls
: Lists all the files in the current directory:mkdir <dir name>
Makes a new directory called directoryName:cd <dir name>
: Changes the current directory to directoryName:cd ..
: Moves up one level of directories (one folder level):pwd
: Tells you where you are in the directory structure at the moment:cp <source> <destination>
: Copy a file from the source to the destinationmv <source> <destination>
: Move a file from the source to the destination (can also be used to rename)
rm filename
: Remove a file (delete)
The -r tag can be added to cp or rm commands to recursively go through a directory and perform the command on all the files
cp -r <source> <desitnation>
Don't worry! We have one for you <3
1511 setup
00000000: 0100 0000 0000 0000 0000 0000 0000 0000
00000010: 1011 0110 0000 0000 0000 0000 0000 0010
00000020: 0000 0100 0110 0000 1001 0000 0000 0000
So machine code is too precise...
Why can't we just say "Hey computer! Add two numbers together!
Precise enough to be translated to machine code
Simple enough that a human can (sometimes) understand it.
A shared language
Why C?
#include <stdio.h>
int main(void)
{
printf("Hello world");
return 0;
}
// loads the standard input/output library
#include <stdio.h>
// the main function, the starting point of our program
int main(void) {
// prints the string to the standard output
printf("Hello world");
// returns 0 to the operating system
return 0;
}
#include <stdio>
#include <stdio>
In this case, we want the Standard Input Output Library
This allows us to make text appear on the terminal
Almost every C program you will write in this course will have this lineint main(void) {
...
}
{
...
}
Between each {
and }
are a block, or group of instructions.
Blocks are very important! They are how we organise code
printf
{
printf("Hello world!");
}
printf() makes text appear on the screen. It is a function from stdio.h which we included.
return 0
return is a C keyword that tells the computer that we are now delivering the output of a function.
A main function that returns 0 is signifying a correct outcome of the program back to the operating system
//
in front of a line makes it a comment`
If we use /*
and */
everything between them will be comments
The compiler will ignore comments, so they can be anything you want really!
Remember, C is a shared language, so we can be productive
Computers can't understand C
We need to turn our C code into machine code using a compiler
That turn code into machine code.
dcc program.c -o helloWorld
./helloWorld
This compiles a C program into an executable called helloWorld, and runs it
But what hasn't changed
The Beginning