fork download
  1. //Andres Guzman CSC5 Chapter 5, P. 294, #2
  2. //
  3. /*******************************************************************************
  4. *
  5. * DISPLAY ASCII CODE
  6. * ______________________________________________________________________________
  7. * This program will convert integers to their corresponding ASCII character and
  8. * creates a new line every 16 characters
  9. *
  10. * Computation is based on the formula:
  11. *
  12. * Input Validation: num <= 127
  13. * (num + 1) % 16 == 0, num++
  14. * ______________________________________________________________________________
  15. * INPUT
  16. *
  17. * None
  18. *
  19. * OUTPUT
  20. *
  21. * The corresponding character according to the converted integer
  22. *
  23. *******************************************************************************/
  24. #include <iostream>
  25. using namespace std;
  26. int main ()
  27. {
  28. int num = 0; //counter for ASCII characters
  29. //
  30. //Initalizing While Loop to go through characters
  31. while( num <= 127)
  32. {
  33. cout << static_cast<char>(num); //converts integer into corresponding
  34. //character.
  35. if((num + 1) % 16 == 0) //Forms a new line every time the
  36. //remainder is 0.
  37. {
  38. cout << endl;
  39. }
  40. num++; //Adds a value of 1 each loop, switching
  41. //characters.
  42. }
  43. return 0;
  44. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
	



 !"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~