Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Formatted output of real numbers

Posted By: Caitlin Brown     Category: C Programming     Views: 4433

Formatted output of real numbers.

Code for Formatted output of real numbers in C Programming

   main()                                                      
   {                                                           
       float y = 98.7654;                                      
       printf("%7.4f\n", y);                                   
       printf("%f\n", y);                                      
       printf("%7.2f\n", y);                                   
       printf("%-7.2f\n", y);                                  
       printf("%07.2f\n", y);                                  
       printf("%*.*f", 7, 2, y);                               
       printf("\n");                                           
       printf("%10.2e\n", y);                                  
       printf("%12.4e\n", -y);                                 
       printf("%-10.2e\n", y);                                 
       printf("%e\n", y);                                      
   }                                                           
Output      98.7654                                                     
           98.765404                                                   
             98.77                                                     
           98.77                                                       
           0098.77                                                     
           98.77                                                     
           9.88e+001                                                  
           -9.8765e+001                                                
           9.88e+001                                                 
           9.876540e+001                                                                                             
  
Share: 


Didn't find what you were looking for? Find more on Formatted output of real numbers Or get search suggestion and latest updates.

Caitlin Brown
Caitlin Brown author of Formatted output of real numbers is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!