Advertisement
dmilicev

for loop without continue and break v2.c

Oct 12th, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. /*
  2.     Better solution :
  3.  
  4.     for loop without continue and break v2.c
  5.  
  6. */
  7.  
  8. #include "stdio.h"
  9.  
  10. int main(void)
  11. {
  12.     int i, n=15, min=5, max=10, counter=0;
  13.  
  14.     printf("\n min = %d , max = %d , n = %d \n\n", min, max, n);
  15.  
  16.     for (i=0; i<n; i++)
  17.     {
  18.         if( i<min || i>max )
  19.         {
  20.             printf("\n i = %2d , continued \n",i);
  21.         }
  22.         else
  23.         {
  24.             counter++;
  25.             printf("\n i = %2d      counter %2d.        * \n", i, counter);
  26.         }
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement