Thread: printing floating number

  1. #1
    Registered User
    Join Date
    Oct 2018
    Posts
    4

    printing floating number

    Hi,

    Can someone please explain why this prints out 0.000000? I'm new to C and not really understanding printing.

    Code:
    
    
    
    
    
    #include <stdio.h>
    
    
    
    
    int main() {
    
    
        int number = 10;
        
       printf("%f", number);
        
        
    }

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    3,729
    %f is for printing floating point number; you passed it an integer, instead.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Oct 2018
    Posts
    4
    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Floating Point Number + NAN
    By sonia 1985 in forum C Programming
    Replies: 2
    Last Post: 05-09-2014, 07:57 PM
  2. Big Floating Number, 100! Not right.
    By KAUFMANN in forum C Programming
    Replies: 7
    Last Post: 01-19-2011, 07:48 PM
  3. Floating point number
    By Mckooy in forum C Programming
    Replies: 1
    Last Post: 01-15-2006, 07:28 AM
  4. problem printing with floating number
    By ssharish in forum C++ Programming
    Replies: 4
    Last Post: 01-25-2005, 07:31 PM
  5. floating and double number
    By kashifk in forum C++ Programming
    Replies: 2
    Last Post: 05-09-2003, 09:52 PM

Tags for this Thread