Please help a beginner with float...

This is a discussion on Please help a beginner with float... within the C Programming forums, part of the General Programming Boards category; *question answered*...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    22

    Please help a beginner with float...

    *question answered*
    Last edited by BobDole11; 09-14-2008 at 12:07 PM. Reason: tabstop helped me

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    %d says "the thing being passed in is an integer" while %f says "the thing being passed in is a float (actually, a double)". So just change %d to %f when you have a decimal point thing.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    22
    Okay, so i changed the %d's to %f's in the instances where I use 3.14159, but how would i do it so you can input a whole number integer or a decimal?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Same deal -- but of course be sure you store it in "float radius" and not "int radius". (A float can handle 3 just as well as it can handle 8.76.)

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    22
    Alright, thanks man

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-13-2009, 04:25 PM
  2. Replies: 14
    Last Post: 06-28-2006, 02:58 AM
  3. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 12:58 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21