Hey guys, I wrote a program for our assignment, and I'm having only one problem with it. The program is supposed to ask for an integer, find integers divisible by 5 between 1 and the integer you gave, list them, and give the count. My program does this, but for some reason it wont include the number you input.
Like for example, I input the number 20, and the output gives:
It wont include the number given, and its not supposed to count '0'. Here's my program:Enter a positive integer: 20
15
10
5
0
the count is 4
What am I doing wrong?Code:#include <stdio.h> int main(void) { int n; int count = 0; printf("Enter a positive integer: "); scanf("%d", &n); { for(n>1; n-- ;) if(n%5 == 0){ printf("%d\n", n); count++;} printf("The count is %d\n", count); } }