Public paste
here
By: jewass | Date: Nov 10 2006 22:13 | Format: C++ | Expires: never | Size: 712 B | Hits: 1441

  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10. cout<<"Enter a number between 0-127 to see it's ASCI equivelent, '-999' will terminate program:n";
  11.  
  12. int input=0;
  13. char cCh;
  14. bool show = true;
  15.  
  16. while (input != -999) {
  17. show = true;
  18. cin>>input;
  19.  
  20. if ((input < 0 && input != -999) || (input > 127 && input != -999)) {
  21.         cout<<input<<" is out of range!n";
  22.         show = false;
  23. }
  24.  
  25.  
  26. cCh = static_cast<char>(input);
  27. if (input !=-999 && show)
  28. cout<<input<<"t"<<cCh<<endl;
  29.  
  30. else if (input == -999)
  31. cout<<"Thanks for using this program!n";
  32. }
  33. return 0;
  34.  
  35. }
  36.  
  37. //test runs 0, 12, 33, 45, 48, 57, 58, 65, 90, 91, 97, 122, 123, 127, 166, 164, -5, and 251