fork download
  1. //Ncolas Ruano CS1A Pp. 294 #2
  2. /******************************************************************************
  3.  * WRITING CHARACTERS FOR THE ASCII CODES
  4.  *
  5.  * In this program, we are figuring inputing a set of numbers that are listed
  6.  * from characters 0, all the way towards 127
  7.  *
  8.  ******************************************************************************
  9.  *
  10.  * INPUT
  11.  * list out ASCII characcters from 0-127
  12.  *
  13.  * The for loop will start with the first code, which is 0, and the code that
  14.  * it <= 127
  15.  *
  16.  * Then, print out 16 characters
  17.  *
  18.  * OUTPUT
  19.  * Display 16 characters on each line.
  20. ******************************************************************************/
  21. #include <iostream>
  22. #include <iomanip>
  23. using namespace std;
  24.  
  25. int main() {
  26. cout << "List ASCII Characters, starting from 0 to 127\n"; //input list
  27. cout <<"______________________________________________\n";
  28.  
  29.  
  30. for (int code = 0; code <= 127; code++) {
  31. cout << setw(3) << code << ": ";
  32.  
  33.  
  34. if (code < 32 || code == 127)
  35. cout << "NP "; // NP = Non-Printable
  36. else
  37. cout << (char)code << " ";
  38.  
  39. // Print 16 characters per line
  40. if ((code + 1) % 16 == 0)
  41. cout << endl;
  42.  
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5332KB
stdin
Standard input is empty
stdout
List ASCII Characters, starting from 0 to 127
______________________________________________
  0: NP   1: NP   2: NP   3: NP   4: NP   5: NP   6: NP   7: NP   8: NP   9: NP  10: NP  11: NP  12: NP  13: NP  14: NP  15: NP 
 16: NP  17: NP  18: NP  19: NP  20: NP  21: NP  22: NP  23: NP  24: NP  25: NP  26: NP  27: NP  28: NP  29: NP  30: NP  31: NP 
 32:    33: !  34: "  35: #  36: $  37: %  38: &  39: '  40: (  41: )  42: *  43: +  44: ,  45: -  46: .  47: / 
 48: 0  49: 1  50: 2  51: 3  52: 4  53: 5  54: 6  55: 7  56: 8  57: 9  58: :  59: ;  60: <  61: =  62: >  63: ? 
 64: @  65: A  66: B  67: C  68: D  69: E  70: F  71: G  72: H  73: I  74: J  75: K  76: L  77: M  78: N  79: O 
 80: P  81: Q  82: R  83: S  84: T  85: U  86: V  87: W  88: X  89: Y  90: Z  91: [  92: \  93: ]  94: ^  95: _ 
 96: `  97: a  98: b  99: c 100: d 101: e 102: f 103: g 104: h 105: i 106: j 107: k 108: l 109: m 110: n 111: o 
112: p 113: q 114: r 115: s 116: t 117: u 118: v 119: w 120: x 121: y 122: z 123: { 124: | 125: } 126: ~ 127: NP