duquesne9

Loop demo

Oct 16th, 2020 (edited)
905
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6.     int x = 4;
  7.     while (x < 1 || x > 8);
  8.     int i;
  9.     for (i = 0; i < x; x--){
  10.         for (i=0; i<x; i++){
  11.             printf("This is the inner loop i=%i ", i);
  12.         }
  13.         printf("This is the outer loop x=%i\n ", x);
  14.     }
  15.     printf("\nafter first loop x = %i\n", x);
  16.     printf("\n\nNEXT LOOP\n\n\n");
  17.     x=4;
  18.     int l, k;
  19.     for (k = 0; k < x; x--){
  20.         for (l=0; l<x; l++){
  21.             printf("This is the inner loop l=%i " ,l);
  22.         }
  23.         printf("This is the outer loop x=%i\n ", x);
  24.     }
  25.  
  26. }
RAW Paste Data