Problem determining if the first integer is an integer multiple of the second integer

Hello everyone.

I am attempting to write a program that reads in 2 integers and determines if the first number is an integer multiple of the second number. I'm using the % operator. I'm also trying to determine if the second number is an integer multiple of the first number.

So far this is what I have. While it is working for the first if statement it will not work for the second if statement. What am I missing or what am I doing wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  #include "stdio.h"

int x, y;

void main()

{
	printf("Please enter in the first whole number\n");
	scanf("%d", &x);
	printf("Please enter in the second whole number\n");
	scanf("%d", &y);

	if ((x % y) == 0)
		printf("The number %d is a multiple of %d\n",x,y);
	if ((y % x) == 0)
		printf("The number %d is a multiple of %d\n",y,x);
}


Any and all help will be greatly appreciated. I think I've done 95% of the work, I just can't figure out for the life of me why it wont work all the way.
Please give a sample of input and output that you consider be wrong.
condor,

thanks for attempting to assist me. I figured out what was the issue a little while ago. but thanks anyways.

=)
Topic archived. No new replies allowed.