#include <stdio.h>
int main()
{
int start;
int stop;
int step;
int iteration;
printf("Starting number:\n");
scanf("%d",&start);
printf("Stopping number:\n");
scanf("%d",&stop);
printf("Step size:\n");
scanf("%d",&step);
printf("Using a for loop:\n");
printf("\nStarting at %d...\n\n",start);
for(int i = start; i<=stop;i+=step)
{
printf("In loop: %d...\n",i);
iteration++;
}
printf("\nStopping at %d...\n",stop);
printf("\nThis loop did %d iterations.\n",iteration);
printf("\n");
printf("\n");
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter