Find all numbers between an interval, divisible by a specific number
C program to find all numbers between an interval, divisible by a specific number, where range for interval and number is entered by user.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int num1, num2, n;
int i;
printf("Enter two integers (interval)\t:");
scanf("%d%d",&num1,&num2);
printf("Enter the number by which divisibility is to be checked\t:");
scanf("%d",&n);
printf("\nNumbers between %d and %d, divisible by %d are \n",num1,num2,n);
for(i=num1;i<=num2;i++)
{
if(i%n==0)
{
printf("%d, ",i);
}
}
getch();
}
Output
Enter two integers (interval) :25
250
Enter the number by which divisibility is to be checked :24
Numbers between 25 and 250, divisible by 24 are
48, 72, 96, 120, 144, 168, 192, 216, 240,