So i wrote out a snippet of my code for a program that is supposed to add and later simplify two fractions. To check if the first part of my program was working, I ran a side program with this code:
I printed out values for a b c and d to make sure the computer was getting the correct values from the user. The user's input is supposed to be in this form: a/b + c/d wherein a b c and d are provided by the user. For some reason, whatever is inputted in the d variable, the program still prints out 1 for the d variable. The other variables are fine. Because the d always comes out as 1, then the corresponding variables that rely on what d is come out wrong.
int a, b, c, e, num, first, second, den, whole, newnum, t;
scanf("%d/%d + %d/%d", &a, &b, &c, &d);
printf("Invalid input: Denominator cannot be zero!");
printf("%d %d %d %d\n", a, b, c, d);
printf("%d %d %d %d\n", first, second, num, den);
Please help! I cant seem to locate the problem. Here is a snippet of what happens when i run this program