C Program to Print All Numbers from 1 to n Divisible by m using For Loop

C Program to Print All Numbers from 1 to n Divisible by m using For Loop

Write a Program to Print All Numbers from 1 to n Divisible by m using For Loop

// C Program to Print All Numbers from 1 to n Divisible by m using For Loop

#include <stdio.h>

int main()
{
	int n, m, i;

	printf("Enter n :--> ");
	scanf("%d", &n);

	printf("Enter m :--> ");
	scanf("%d", &m);

	printf("The divisible numbers between 1 to %d by %d :--> ", n, m);

	for(i = 1; i < n; i++ )
	{
		if(i % m == 0)
		{
			printf("%d ",i);
		}
	}

	return 0;
}

Output:

Enter n :--> 24
Enter m :--> 4

The divisible numbers between 1 to 24 by 4 :--> 4 8 12 16 20