Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
hello-world
c_cpp_and_make
Commits
00e7a3c4
Commit
00e7a3c4
authored
Oct 21, 2020
by
Erik Strand
Browse files
Update READMEs
parent
4de03d3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
02_fundamentals/Makefile
View file @
00e7a3c4
...
...
@@ -5,21 +5,21 @@ CXX = g++
CFLAGS
=
-Wall
-O3
.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
# 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
# typing if you decide to rename things.
control_structures
:
control_structur
es.c
basic_types
:
basic_typ
es.c
$(CC)
$(CFLAGS)
-o
$@
$<
functions
:
function
s.c
control_structures
:
control_structure
s.c
$(CC)
$(CFLAGS)
-o
$@
$<
basic_types
:
basic_type
s.c
functions
:
function
s.c
$(CC)
$(CFLAGS)
-o
$@
$<
.PHONY
:
clean
clean
:
rm
-f
control_structures functions
basic_types
rm
-f
basic_types
control_structures functions
02_fundamentals/README.md
View file @
00e7a3c4
#
Control Structure
s
#
Fundamental
s
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
gcc -Wall -O3 -o loops loops.c
demo@linux:02_fundamentals$ make
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
```
```
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: 1
while loop: 2
...
...
@@ -25,7 +68,9 @@ leaving the while loop
1 is odd
3 is odd
i is 42
```
```
demo@linux:02_control_structures$ ./functions
two is even
three is odd
...
...
README.md
View file @
00e7a3c4
...
...
@@ -49,4 +49,5 @@ On Windows... honestly I'm not sure. I haven't set up a development environment
## Examples
-
[
hello world
](
./01_hello_world
)
-
[
control structures
](
./02_control_structures
)
-
[
fundamentals
](
./02_fundamentals
)
-
[
inputs and outputs
](
./03_inputs_and_outputs
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment