CSC231 OverFlow C Program
Revision as of 10:18, 22 September 2008 by Thiebaut (talk | contribs) (New page: Back to Weekly Schedule ---- =A C++ Program that overflows= <code><pre> // mulby2.cpp // D. Thiebaut // demonstrates how a compiled language deals with an overflow...)
A C++ Program that overflows
// mulby2.cpp
// D. Thiebaut
// demonstrates how a compiled language deals with an overflow.
// check mulby2.py to see how an interpreted language will do.
//
#include <iostream.h>
main() {
unsigned int x, lastx;
cout << endl << endl << endl << endl;
x = 1;
cout << "x = " << x << endl;
while ( 1 ) {
lastx = x;
x = x * 2;
if ( x <= lastx ) {
cout << "last x = " << lastx << endl;
cout << "x = " << x << endl;
break;
}
}
cout << endl << endl << endl << endl;
}