OT: Being a total beginner to programming but having lots of free time I recently started practicing. Having a rough time on functions. Thanks to everyone in advance.
THE PROBLEM:
Given 2 integers N and M from standard input, using a multiples function, calculate the integers in [1,N] multiple of M. Print the sets in increasing order.
MY (WRONG) SOLUTION:
Code:
#include <stdio.h>
int multipli(int,int);
int multipli (int x, int y)
{
int i;
for (i=1;i<=x;i++)
{
if((i%y)==0)
{
return i;
}
}
}
int main(void)
{
int N;
int M;
scanf("%d", &N);
scanf("%d", &M);
printf("%d", multipli(N,M));
return 0;
}
Thanks again in advance.