|
CS256 - Principles of Structured Design
Fall 2021
|
Displaying ./code/cs256su21code/jun01/count5.c
/*
similar to count4.c but now we are specifying how much we increment by
*/
#include <stdio.h>
int main()
{
int num, start, inc, end;
printf("Starting Number: ");
scanf("%d", &start);
printf("Counting up by?: ");
scanf("%d", &inc);
printf("Ending Number: ");
scanf("%d", &end);
num = start;
while(num <= end){
printf("%d\n", num);
num = num + inc;
//if we want to increment a value by something other than 1, a statement like the one
//above would be one way to do it.
}
return 0;
}
|