C code, cycles and the sum of multiples

I was stuck and I could use a fresh set of eyes.

Here's the question: Create a cycle that calculates the sum of multiples of 8, which are between 100 and 500. Print the amount.

Here is my code

My problem is when, if I say ... while (multiple> 100 && multiple <500), my only conclusion is "press any key to continue." If I edit it so to speak, so far (several and 500) is working fine, but includes multiple values ​​below 100, which I do not need.

I do not understand why he will not let me say so far (several> 100 && multiple <500)

Any help would be greatly appreciated.

int number = 8, count = 1, multiple = 0, sum = 0;
while (multiple < 500) {
    multiple = number * count;
    count = ++count;
    printf("Your multiple is: %i \n", multiple);

}

sum = multiple * count;
count = ++count;
printf("Your sum of the multiples are: %i \n", sum);


system("pause");
+4
source share
2 answers

while(multiple > 100), multiple 0. .

:

while (multiple < 500) {
    multiple = number * count;
    count = ++count;
    if (multiple > 100) {
        printf("Your multiple is: %i \n", multiple);
    }
}
+2

, : count = 101; , , 100 500.

, .

0

All Articles