Fraction to float

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2009
Posts: 5
Reputation: kat_stephens is an unknown quantity at this point 
Solved Threads: 0
kat_stephens kat_stephens is offline Offline
Newbie Poster

Fraction to float

 
0
  #1
Nov 2nd, 2009
I'm currently working with a group of my classmates on a recipe measurement converter, and I'm currently on the most difficult code of the three that is my part of the project. The code is basically for getting the amount from the user, a fraction. I have based my algorithm as reading the fraction as a string and converting it into an int. I haven't got a decent piece of code together yet, I'm still jotting out my algorithm and just keep getting turned around...please if someone can help with any ideas please do so I might can make a start at this!!! Thanks so much! Kat
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 70
Reputation: Iam3R is an unknown quantity at this point 
Solved Threads: 3
Iam3R Iam3R is online now Online
Junior Poster in Training
 
0
  #2
Nov 2nd, 2009
Originally Posted by kat_stephens View Post
I'm currently working with a group of my classmates on a recipe measurement converter, and I'm currently on the most difficult code of the three that is my part of the project. The code is basically for getting the amount from the user, a fraction. I have based my algorithm as reading the fraction as a string and converting it into an int. I haven't got a decent piece of code together yet, I'm still jotting out my algorithm and just keep getting turned around...please if someone can help with any ideas please do so I might can make a start at this!!! Thanks so much! Kat

without code its highly difficult to get the help here (-
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,466
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 189
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso
 
0
  #3
Nov 3rd, 2009
You mean the input is something like this ?
  1. <enter fraction > 123/452

And its read as a string.

If so then separate the string into 2 components the left side before the '/' character and the right side, after the '/' character. Then use the
atoifunction .
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle.
2) Problem 2[b]solved by : jonsca
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 223 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC