Solved

# Fraction inputs

Posted on 2001-06-17

I have only just started a course in 'C', as you can see below I havent got very far.

I need to know how to enter a fraction as 1/4 rarther than 14 as i have set it below.

Any help would be nice.

Thanks Guys..

#include <stdio.h>

void main()

{

int fraction;

printf("\nEnter a Fraction 1/4 as 14 same with other Fractions\n");

printf("for the decimal equivalent ");

scanf("%d", &fraction);

if( fraction == 1/4 )

printf(" The Decimal equivalent for 1/4 is 0.25 ");

else

if( fraction == 1/3 )

printf(" The Decimal equivalent for 1/3 is 0.33 ");

}