C Program to Print Numbers Between 1 and n Divisible By m using While loop
Write C Program to Print Numbers Between 1 and n Divisible By m using While loop
//WAP to print all the numbers from 1 to n divisible by m
#include <stdio.h>
int main()
{
int n, m;
printf("Enter n :--> ");
scanf("%d", &n);
printf("Enter m :--> ");
scanf("%d", &m);
printf("The divisible numbers between 1 to %d by %d :--> ", n, m);
int i = 1;
while(i < n)
{
if(i % m == 0)
{
printf("%d ",i);
}
i++;
}
return 0;
}
Output:
Enter n :--> 24
Enter m :--> 4
The divisible numbers between 1 to 24 by 4 :--> 4 8 12 16 20