Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
c_cpp_and_make
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
hello-world
c_cpp_and_make
Commits
00e7a3c4
Commit
00e7a3c4
authored
4 years ago
by
Erik Strand
Browse files
Options
Downloads
Patches
Plain Diff
Update READMEs
parent
4de03d3d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
02_fundamentals/Makefile
+5
-5
5 additions, 5 deletions
02_fundamentals/Makefile
02_fundamentals/README.md
+50
-5
50 additions, 5 deletions
02_fundamentals/README.md
README.md
+2
-1
2 additions, 1 deletion
README.md
with
57 additions
and
11 deletions
02_fundamentals/Makefile
+
5
−
5
View file @
00e7a3c4
...
@@ -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_structur
es.c
basic_types
:
basic_typ
es.c
$(
CC
)
$(
CFLAGS
)
-o
$@
$<
$(
CC
)
$(
CFLAGS
)
-o
$@
$<
functions
:
function
s.c
control_structures
:
control_structure
s.c
$(
CC
)
$(
CFLAGS
)
-o
$@
$<
$(
CC
)
$(
CFLAGS
)
-o
$@
$<
basic_types
:
basic_type
s.c
functions
:
function
s.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
This diff is collapsed.
Click to expand it.
02_fundamentals/README.md
+
50
−
5
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
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
...
...
This diff is collapsed.
Click to expand it.
README.md
+
2
−
1
View file @
00e7a3c4
...
@@ -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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment