fork download
  1. //Amari Mosley CSC5 Chapter 5, P. 294, #2
  2. //
  3. /**************************************************************
  4. *
  5. * DISPLAY CHARACTERS FOR ASCII CODES
  6. *____________________________________________
  7. * This program uses a loop to display the characters for the
  8. * ASCII codes 0 through 127, formatting the output so that
  9. * 16 characters are displayed on each line.
  10. *
  11. * INPUT
  12. * (None) : Program uses a fixed loop range from 0 to 127
  13. *
  14. * OUTPUT
  15. * ASCII Table : Characters corresponding to ASCII codes 0-127
  16. *
  17. **************************************************************/
  18.  
  19. #include <iostream>
  20.  
  21. using namespace std;
  22.  
  23. int main() {
  24. // Loop through ASCII codes from 0 to 127
  25. for (int i = 0; i <= 127; i++) {
  26. // Display the character for the current ASCII code
  27. cout << static_cast<char>(i) << ' ';
  28.  
  29. // Display 16 characters on each line by checking if
  30. // the current index + 1 is a multiple of 16
  31. if ((i + 1) % 16 == 0) {
  32. cout << endl;
  33. }
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 5312KB
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 { | } ~