From 2cd866e3fa0cbec2b53a3b5851792da320fc1c71 Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Tue, 10 Mar 2020 13:38:39 -0600 Subject: Running two examples from cbook --- cbook/one_one.c | 34 ++++++++++++++++++++++++++++++++++ cbook/one_two.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 cbook/one_one.c create mode 100644 cbook/one_two.c (limited to 'cbook') diff --git a/cbook/one_one.c b/cbook/one_one.c new file mode 100644 index 0000000..9896026 --- /dev/null +++ b/cbook/one_one.c @@ -0,0 +1,34 @@ +#include + +/* +* Tell the compiler that we intend +* to use a function called show_message. +* It has no arguments and returns no value +* This is the "declaration". +* +*/ + +void show_message(void); +/* +* Another function, but this includes the body of +* the function. This is a "definition". +*/ +int main(){ + int count; + + count = 0; + while(count < 10){ + show_message(); + count = count + 1; + } + + return(0); +} + +/* +* The body of the simple function. +* This is now a "definition". +*/ +void show_message(void){ + printf("hello\n"); +} diff --git a/cbook/one_two.c b/cbook/one_two.c new file mode 100644 index 0000000..a5bf221 --- /dev/null +++ b/cbook/one_two.c @@ -0,0 +1,36 @@ +/* +* +* Dumb program that generates prime numbers. +*/ +#include +#include + + +int is_prime(int x) { + for (int i=2; i