Example solution

Dependencies:   mbed

Revision:
0:01dd860642c5
--- /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");
+
+}