Midterm Completion
++ midterm.c ++ outRelease (precompiled file for UNIX systems)
This commit is contained in:
parent
6269fbc4ce
commit
e68af45401
2 changed files with 40 additions and 0 deletions
40
Midterm/midterm.c
Normal file
40
Midterm/midterm.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue