Craig Evans
/
1620_Lab2_Task7
Example solution
main.cpp
- Committer:
- eencae
- Date:
- 2017-02-02
- Revision:
- 0:01dd860642c5
File content as of revision 0:01dd860642c5:
/* 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"); }