40 lines
No EOL
1,002 B
C
40 lines
No EOL
1,002 B
C
// header files
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
// local constants
|
|
|
|
/*
|
|
Name: Multiples Printer
|
|
Process: Given a start, stop, step, print all numbers between the values of
|
|
start and stop by step.
|
|
Function input/parameters: NONE
|
|
Function output/parameters: NONE
|
|
Function output/returned: NONE
|
|
Device input/---: NONE
|
|
Device output/---: NONE
|
|
Dependencies: included by standard libraries
|
|
*/
|
|
int main()
|
|
{
|
|
// define local variables
|
|
int start = 10, stop = 30, step = 4, currentNumber;
|
|
// do calculations
|
|
currentNumber = start;
|
|
while(currentNumber < stop)
|
|
{
|
|
// print out the multiple if % returns 0
|
|
if(currentNumber % step == 0)
|
|
{
|
|
printf("%d\n", currentNumber);
|
|
}
|
|
// update the currentNumber
|
|
currentNumber = currentNumber + 1;
|
|
}
|
|
// display results
|
|
// done in do calculations
|
|
// return success
|
|
return 0;
|
|
} |