fork download
  1. //Jeremy Huang CS1A Chapter 5, P. 294, #2
  2. //
  3. /**************************************************************
  4.  *
  5.  * OUTPUT ASCII 0-127
  6.  * ____________________________________________________________
  7.  * This program uses a loop to display the characters for the
  8.  * ASCII codes 0 through 127.
  9.  * ____________________________________________________________
  10.  * INPUT
  11.  *
  12.  * OUTPUT
  13.  *
  14.  **************************************************************/
  15.  
  16. #include <iostream>
  17. using namespace std;
  18.  
  19. int main() {
  20. const int CHARS_PER_LINE = 16;
  21.  
  22. //Output Result
  23. for (int i = 0; i <= 127; ++i) {
  24. char asciiChar = i;
  25. cout << asciiChar;
  26. cout << " ";
  27.  
  28. if ((i + 1) % CHARS_PER_LINE == 0) {
  29. cout<<endl;
  30. }
  31. }
  32. cout<<endl;
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
         	 
   
   
                
  ! " # $ % & ' ( ) * + , - . / 
0 1 2 3 4 5 6 7 8 9 : ; < = > ? 
@ A B C D E F G H I J K L M N O 
P Q R S T U V W X Y Z [ \ ] ^ _ 
` a b c d e f g h i j k l m n o 
p q r s t u v w x y z { | } ~