#include <stdio.h>

int main (void) {
    int divisor;       // remember the divisor
    int loopCounter;
    int finishNumber;

    // Take the user input numbers
    printf("Please enter the divisor:\n");
    scanf("%d", &divisor);
    printf("Please enter the highest possible value:\n");
    scanf("%d", &finishNumber);

    // Get the loop ready by setting up the starting number
    loopCounter = divisor;

    // Loop from loopCounter to finishNumber, 
    // printing multiples of divisor
    while (loopCounter <= finishNumber) {
        printf("%d\n", loopCounter);
        // immediately jump to the next multiple of divisor
        loopCounter = loopCounter + divisor;
    }
    return 0;
}

Resource created Tuesday 05 March 2019, 03:28:39 PM.

file: multiples.c


Back to top

COMP1511 19T1 (Programming Fundamentals) is powered by WebCMS3
CRICOS Provider No. 00098G