Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit c7d9ab0a6c7c5d40bc10861c7e3cf5830e48033a Sam Breed committed Oct 9, 2011
Showing with 116 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +7 −0 Makefile
  3. +12 −0 ex1.c
  4. +14 −0 ex4.c
  5. +22 −0 ex6.c
  6. +30 −0 ex7.c
  7. +30 −0 ex8.c
@@ -0,0 +1 @@
+*.dSYM
@@ -0,0 +1,7 @@
+CFLAGS=-Wall -g
+SOURCES=ex1 ex4 ex6 ex7 ex8
+
+all: $(SOURCES)
+
+clean:
+ rm -f $(SOURCES)
12 ex1.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int main()
+{
+ int wut = 10;
+ int dblwut = 69;
+
+ printf("wuuuut %d\n", wut);
+ printf("wut wuuuut %d\n", dblwut);
+
+ return 0;
+}
14 ex4.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+/* this is broke on porpoise */
+
+int main()
+{
+ int wut = 10;
+ int dblwut;
+
+ printf("wut %d", wut);
+ printf("wut wut %d", dblwut);
+
+ return 0;
+}
22 ex6.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ int distance = 100;
+ float power = 2.345f;
+ double super_power = 56789.4532;
+ char initial = 'M';
+ char first_name[] = "Samuel";
+ char last_name[] = "Breed";
+
+ printf("wuuut %d\n", distance);
+ printf("you have %f power\n", power);
+ printf("wut super power %f\n", super_power);
+ printf("initial %c\n", initial);
+ printf("first name %s\n", first_name);
+ printf("last name %s\n", last_name);
+ printf("full name %s %c %s\n",
+ first_name, initial, last_name);
+
+ return 0;
+}
30 ex7.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+
+int main(int argv, char *argc[])
+{
+ int bugs = 100;
+ double bug_rate = 1.2;
+
+ printf("You have %d bugs imaginary rate of %f.\n",
+ bugs, bug_rate);
+
+ long universe_of_defects = 1L * 1024L * 1024L * 1024L;
+ printf("The entire univers has %ld bugs.\n",
+ universe_of_defects);
+
+ double expected_bugs = bugs * bug_rate;
+ printf("You are expected to have %f bugs.\n",
+ expected_bugs);
+
+ double part_of_universe = expected_bugs / universe_of_defects;
+ printf("That is only %e portion of the universe.\n",
+ part_of_universe);
+
+ // this makes no sense, just a weird demo
+ char null_byte = '\0';
+ int care_percentage = bugs * null_byte;
+ printf("Which means you should care %d%%.\n",
+ care_percentage);
+
+ return 0;
+}
30 ex8.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ int areas[] = {10, 12, 13, 14, 20};
+ char name[] = "Sam";
+ char full_name[] = {'S', 'a', 'm', ' ','B','r','e','e','d', '\0'};
+
+ printf("The size of an int: %ld\n", sizeof(int));
+ printf("The size of areas (int[]) %ld\n",
+ sizeof(areas));
+
+ printf("The number of intes in areas: %ld\n",
+ sizeof(areas) / sizeof(int));
+
+ printf("The first area is %d, then the 2nd %d\n",
+ areas[0], areas[1]);
+
+ printf("The size of char %ld\n", sizeof(char));
+ printf("The size of name (char[]) %ld\n", sizeof(name));
+ printf("The numbers of chars %ld\n",
+ sizeof(name) / sizeof(char));
+
+ printf("The size of full_name (char[]) %ld\n", sizeof(full_name));
+ printf("The number of chars: %ld\n", sizeof(full_name) / sizeof(char));
+
+ printf("name=\"%s\" and full_name=\"%s\"\n", name, full_name);
+
+ return 0;
+}

0 comments on commit c7d9ab0

Please sign in to comment.