Skip to content
Snippets Groups Projects
Commit 00e7a3c4 authored by Erik Strand's avatar Erik Strand
Browse files

Update READMEs

parent 4de03d3d
No related branches found
No related tags found
No related merge requests found
...@@ -5,21 +5,21 @@ CXX = g++ ...@@ -5,21 +5,21 @@ CXX = g++
CFLAGS = -Wall -O3 CFLAGS = -Wall -O3
.PHONY: all .PHONY: all
all: control_structures functions basic_types all: basic_types control_structures functions
# Here I'm using some of Make's built in variables: $@ and $<. The former gets substituted with the # Here I'm using some of Make's built in variables: $@ and $<. The former gets substituted with the
# name of the target. In this case, that's "loops". The latter gets substituted with the first # name of the target. In this case, that's "loops". The latter gets substituted with the first
# prerequisite. In this case, that's "loops.c". These are hard to remember, but can save you some # prerequisite. In this case, that's "loops.c". These are hard to remember, but can save you some
# typing if you decide to rename things. # typing if you decide to rename things.
control_structures: control_structures.c basic_types: basic_types.c
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
functions: functions.c control_structures: control_structures.c
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
basic_types: basic_types.c functions: functions.c
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
.PHONY: clean .PHONY: clean
clean: clean:
rm -f control_structures functions basic_types rm -f basic_types control_structures functions
# Control Structures # Fundamentals
These examples demonstrate loops and functions. These examples demonstrate C's basic types, how to use control structures like branches and loops,
and how to write functions.
``` ```
demo@linux:02_control_structures$ make demo@linux:02_fundamentals$ make
gcc -Wall -O3 -o loops loops.c gcc -Wall -O3 -o basic_types basic_types.c
gcc -Wall -O3 -o control_structures control_structures.c
gcc -Wall -O3 -o functions functions.c gcc -Wall -O3 -o functions functions.c
```
```
demo@linux:02_fundamentals$ ./basic_types
Signed Integers
min: -2147483648
max: 2147483647
5 - 10 = -5
Unsigned Integers
min: 0
max: 4294967295
5 - 10 = 4294967291
Floating Point
min: -3.402823e+38
smallest positive (normalized): 1.175494e-38
max: 3.402823e+38
closest float to 1.2: 1.2000000477
1.2 - 0.2: 1.0000000477
(0.001 + 1.0) - 1.0 = 0.001000047
0.001 + (1.0 - 1.0) = 0.001000000
Double Precision Floating Point
min: -1.797693e+308
smallest positive (normalized): 2.225074e-308
max: 1.797693e+308
closest double to 1.2: 1.19999999999999996
1.2 - 0.2: 1.00000000000000000
(1e-6 + 1.0) - 1.0 = 0.000001000000000000024
1e-6 + (1.0 - 1.0) = 0.000001000000000000000
demo@linux:02_control_structures$ ./loops Character
1$
numeric 0 (won't show up as anything):
ASCII 0: 0
Strings
hello
```
```
demo@linux:02_fundamentals$ ./control_structures
while loop: 0 while loop: 0
while loop: 1 while loop: 1
while loop: 2 while loop: 2
...@@ -25,7 +68,9 @@ leaving the while loop ...@@ -25,7 +68,9 @@ leaving the while loop
1 is odd 1 is odd
3 is odd 3 is odd
i is 42 i is 42
```
```
demo@linux:02_control_structures$ ./functions demo@linux:02_control_structures$ ./functions
two is even two is even
three is odd three is odd
......
...@@ -49,4 +49,5 @@ On Windows... honestly I'm not sure. I haven't set up a development environment ...@@ -49,4 +49,5 @@ On Windows... honestly I'm not sure. I haven't set up a development environment
## Examples ## Examples
- [hello world](./01_hello_world) - [hello world](./01_hello_world)
- [control structures](./02_control_structures) - [fundamentals](./02_fundamentals)
- [inputs and outputs](./03_inputs_and_outputs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment