So far so good, but I don't know what to do for this next part where i am asking the user to enter an arithmatic operator (+, -, *, /)...
Code:
void printFraction(int n, int d)
{
printf("%d/%d",n,d);
}
void scanFraction(int *n, int *p)
{
scanf("%d %d",&*n,&*p);
}
char scanOperator(void)
{
char c;
scanf("%c",&c);
}
int main(void)
{
int a,b;
char c;
printf("Enter the numerator and denominator of a common fraction: ");
scanFraction(&a,&b);
for(;b<=0;)
{
printf("The common fraction you entered is invalid.\n");
printf("Enter the numerator and denominator of a common fraction: ");
scanFraction(&a,&b);
}
printf("You have entered: ");
printFraction(a,b);
printf("\n");
printf("Enter an arithmetic operator (+, -, *, /): ");
scanOperator();
system("PAUSE");
return 0;
}
The output should look something like this:
Enter an arithmetic operator (+, -, *, /): .<enter>
The arithmetic operator you entered is invalid.
Enter an arithmetic operator (+, -, *, /): *<enter>
You have entered: *
where the orange is user input.