Good day. I am rather new to these forums and was wondering if I could obtain some assistance with this project. Here is the code and what is happening is that an infinite loop is happening. Any help would be much appreciated for this problem, as I was able to get it to work in php.
Code:
#include <stdio.h>
int main() {
int x, y, div, i, newx, newy;
i = 1;
printf("Type in a fraction: #/#\n");
scanf("%d/%d", &x, &y);
if (x < 0 || y < 0) { printf("No negative numbers\n "); return 1;}
else if (y % x == 0)
{
while (i <= x)
if (x % i == 0 && y % i == 0){
div = i;
}
i++;
}
x = x / div;
y = y / div;
printf("In lowest terms: %d/%d\n", x, y);
return 0;
Thanks again.