fork download
  1. //Zachary Abdollahi CS1A Chapter 5, P. 294, #2
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * OUTPUTTING CHARACTERS FOR ASCII CODES
  6.  *
  7.  * _____________________________________________________________________________
  8.  * This program uses a loop to display the characters for ASCII codes 0 through
  9.  * 127, printing 16 characters per line.
  10.  *
  11.  * INPUT
  12.  * none
  13.  *
  14.  * OUTPUT
  15.  * The characters for ASCII codes 0 through 127
  16.  *
  17.  ******************************************************************************/
  18. #include <iostream>
  19. using namespace std;
  20. int main()
  21. {
  22. char letter; //Character for the current ASCII code
  23.  
  24. // Loop through ASCII codes 0 through 127
  25. for (int code = 0; code <= 127; code ++)
  26. {
  27. letter = code;
  28. cout << letter << " ";
  29.  
  30. // Start a new line after every 16 characters
  31. if ((code + 1) % 16 == 0)
  32. cout << endl;
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 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 { | } ~