C Programming Code Examples C > For Loops and While Loops Code Examples Program to Find the Number of Integers Divisible by 5 Program to Find the Number of Integers Divisible by 5 This is a C Program which calculates the number of integers divisible by 5 in the given range. 1. This program takes the range as input and finds the number of integers divisible by 5 in the given range. 2. Also finds the sum of all integers that are divisible by 5 in the given range. 1. Take the range as input and store it in the variables number1 and number2 respectively. 2. Firstly initialize the variables count and sum to zero. 3. Using the for loop, find all the integers that gives remainder zero when divided by 5 and print them consecutively. 4. Along with this, increment both the variables i.e increment the variable count by 1 and variable sum by the number that is divisible by 5. 5. Print the variables count and sum as output. #include <stdio.h> void main() { int i, number1, number2, count = 0, sum = 0; printf("Enter the value of number1 and number2 \n"); scanf("%d %d", &number1, &number2); /* Count the number and compute their sum*/ printf("Integers divisible by 5 are \n"); for (i = number1; i < number2; i++) { if (i % 5 == 0) { printf("%3d,", i); count++; sum = sum + i; } } printf("\n Number of integers divisible by 5 between %d and %d = %d\n", number1, number2, count); printf("Sum of all integers that are divisible by 5 = %d\n", sum); }