fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int loop_count; // number of times to loop
  5. int idx; // loop index
  6.  
  7. // Prompt for number of times to loop
  8. printf ("Enter the number of times to loop \n");
  9. scanf ("%i", &loop_count);
  10.  
  11. printf ("\nIncrementing; \n");
  12. for (idx = 1; idx <= loop_count; ++idx )
  13. {
  14. printf ("...%i", idx);
  15. }
  16.  
  17. printf ("\n\nDecrementing;\n");
  18. for ( idx = loop_count; idx >= 1; --idx )
  19. {
  20. printf ("...%i", idx );
  21. }
  22.  
  23. return (0);
  24. }
Success #stdin #stdout 0.01s 5292KB
stdin
5
stdout
Enter the number of times to loop 

Incrementing; 
...1...2...3...4...5

Decrementing;
...5...4...3...2...1