Question #38706

Create a program that asks the user for two integers which represent the numerator and denominator parts of fraction.
Print out a simplification of the fraction.
Example:
Enter the numerator: 22
Enter the denominator: 5
22/5 is 4 and 2/5

Expert's answer

#include <stdio.h>

int main() {

int numerator, denominator;

scanf("%d %d",&numerator, &denominator);

printf("%d/%d is %d and %d/%d", numerator, denominator, numerator/denominator, (numerator%denominator), denominator);

return 0;

}

int main() {

int numerator, denominator;

scanf("%d %d",&numerator, &denominator);

printf("%d/%d is %d and %d/%d", numerator, denominator, numerator/denominator, (numerator%denominator), denominator);

return 0;

}

## Comments

## Leave a comment