//This program will ask the user for k, m and n.
//k should not be equal to 1.
//Output all numbers multiple by k between m and n. (ex. k=2,m=5,n=20 output should be 6 8 10...18)
*problem*
How to exit this program when the user assigned k to 1 ?
And why is it that when i assign an even-number to k it will output until n. And n should not appear on the screen. Actually this was already answered by our teacher but i want to know how.
#include <stdio.h>
int main()
{
int k, m, n;
printf("Enter a value for k: ");
scanf("%d",&k);
printf("Enter a value for m: ");
scanf("%d",&m);
printf("Enter a value for n: ");
scanf("%d",&n);
if (k <= 1 )
printf("k should not be equal to one \n");
if ( m < n)
{
while ( m < n )
{
m=m+1;
if ((m%k)==0)
{
printf("\n %d",m);
}
}
}
if (m>n)
printf("\n m should not be greater to n");
getchar();
getchar();
return 0;
}