So I'm writing this program that takes 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:
#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);
}
So far I have gotten the program to run almost flawlessly until it comes to the 2nd if statement. I cannot get this silly program to work correctly. It tells me that the 1st number is a multiple of the 2nd number, but it will not tell me if the 2nd number is a multiple of the first. Any ideas? Any and all help will be greatly appreciated!
Question
Terabojin
Hello guys!
So I'm writing this program that takes 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:
So far I have gotten the program to run almost flawlessly until it comes to the 2nd if statement. I cannot get this silly program to work correctly. It tells me that the 1st number is a multiple of the 2nd number, but it will not tell me if the 2nd number is a multiple of the first. Any ideas? Any and all help will be greatly appreciated!
Tera
Link to comment
Share on other sites
7 answers to this question
Recommended Posts