Outputting floating-point values : Formatted Output Float « Console « C / ANSI-C

Home
C / ANSI-C
1.assert.h
2.Console
3.ctype.h
4.Data Structure Algorithm
5.Data Type
6.Development
7.File
8.Function
9.Language Basics
10.Macro Preprocessor
11.Math
12.math.h
13.Memory
14.Pointer
15.setjmp.h
16.signal.h
17.Small Application
18.stdio.h
19.stdlib.h
20.String
21.string.h
22.Structure
23.time.h
24.wctype.h
C Tutorial
C++
C++ Tutorial
Visual C++ .NET
C / ANSI-C » Console » Formatted Output FloatScreenshots 
Outputting floating-point values
Outputting floating-point values

#include <stdio.h>

void main()
{
   float fp1 = 123.678f;
   float fp2 = 1.2345E6f;
   double fp3 = 98765432.0;
   double fp4 = 11.22334455e-6;

   printf("\n%f  %+f  % 10.4f  %6.4f\n", fp1, fp2, fp1, fp2);
   printf("\n%e  %+E\n", fp1, fp2);
   printf("\n%f  %g  %#+f  %8.4f  %10.4g\n", fp3,fp3, fp3, fp3, fp4);
}


           
       
Related examples in the same category
1.Output float with format: round
2.Printf with format
3.Use printf to control the output format
4.More output format with printf
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.