Example solution

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
eencae
Date:
Thu Feb 02 14:07:40 2017 +0000
Commit message:
Initial commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 01dd860642c5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 02 14:07:40 2017 +0000
@@ -0,0 +1,24 @@
+/* ELEC1620 Lab 2 Task 7
+
+Overflow
+
+(c) Dr Craig A. Evans, Feb 2017
+
+*/
+
+#include "mbed.h"
+
+int main()
+{
+    // use the 'signed' keyword when declaring the variable
+    signed char c = 127;
+    printf("c has a value of %d\n",c);
+
+    printf("We'll now incrememt it by 1\n");
+    c++; // increment operator, could also do c = c + 1;
+
+    printf("Now it has a value of %d\n",c);
+    printf("Wow! This is overflow in action!\n");
+    printf("The number has gone out of the range of an 8-bit value.\n");
+
+}
diff -r 000000000000 -r 01dd860642c5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 02 14:07:40 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5
\ No newline at end of file