Can we print rational numbers instead of decimal ratios?
for example,
a=3;
b=4;
if we print a/b, we have to get 3/4 instead of 0.75

Can we print rational numbers instead of decimal ratios?
for example,
a=3;
b=4;
if we print a/b, we have to get 3/4 instead of 0.75

Hi Harikrishna,

If you just want to print as rational number use printf statement as below a=3, b=4 then to print as 3/4 printf("%d/%d",a,b);

yes, that's the way

a=3;
b=4;
printf("%d/%d",a,b);

can i know how can we print a hexadecimal number of the rational number..
pls..

Do you want to use the %x or %X (hexadecimal) format in printf()?

printf("\n%x/%x \n",numerator, denominator); //or X for upper case letters
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.