Advertisement
Guest User

zosi

a guest
Apr 29th, 2010
1,945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. /* Changing the loop to count n down rather than i. The problem is set up so that you view i as the active variable in the loop, but it doesn't have to be. */
  2. int i, n=42;
  3. main() {
  4.     for(i=0; i<n; n--) {
  5.         printf("*");
  6.     }
  7. }
  8. /* Changing the loop so that i == -42 is the terminating condition rather than i == 42.  */
  9. int i, n=42;
  10. main() {
  11.     for(i=0; -i<n; i--) {
  12.         printf("*");
  13.     }
  14. }
  15. /* Same mechanic as #2, but with a less obvious way to do the comparison. */
  16. int i, n=42;
  17. main() {
  18.     for(i=0; i+n; i--) {
  19.         printf("*");
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement