logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/h5sol/counting.c

/*

counting.c

We are writing yet another loop:

You will start with a user specified number, then count up by 1 to another 
number specified by the user, but there will be a third specified number, where
we are going to skip numbers divisible by this number.


*/


#include <stdio.h>

int main(){

	int start, end, skip;//variable declarations

	//ask the user where to start
	//then put input into variable "start" using scanf
	printf("Enter Starting Point: ");
	scanf("%d", &start);

	///ask user for ending point
	//put input into variable "end" using scanf
	printf("Enter Ending Point: ");
	scanf("%d", &end);

	//ask user what numbers we're skipping
	//put input into variable "skip" using scanf
	printf("Skip Numbers divisible by: ");
	scanf("%d", &skip);

	//write a for loop
	// start the loop at "start"
	// loop while i is less than or equal to "end"
	// then increment i by 1  

	for(int i = start; i <=end; i++){

		//if i mod skip is not zero, print the number
		if(i % skip !=0)
			printf("%d\n", i);

	}
	// then print "Done" once finished
	printf("Done\n");

	return 0;

}