Advertisement
Guest User

Untitled

a guest
Oct 15th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1.  
  2. /*
  3. * File: ASCII
  4. * Author: Nunya Buzzy
  5. * Created on October 12, 2016, 10:38 AM
  6. * Purpose: Program displays the ASCII characters 0-127.
  7. Outputs 16 chars per line.
  8. */
  9.  
  10. #include <iostream> //Input/output objects
  11.  
  12. using namespace std;
  13.  
  14. //Execution for the main function
  15. int main() {
  16. //Initialize variables
  17. int t = 1; //ASCII value
  18.  
  19. //For loop to output the ASCII characters.
  20. for (int i = 1; i < 127; i++) {
  21. cout << static_cast<char> (i); //Turns number int into ASCII & outputs
  22. while (t > 16) { //Outputs an endl; every 16 times the for loop loops.
  23. cout << endl; //starts new line
  24. t = 1; //resets while loop counter
  25. }
  26. t++;//increments while loop counter.
  27. } //how many loops could a for loop loop if a for loop could loop fors
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement