Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

%g and %e in c

[1]
E = exponent expression, simply means power(10, n) or 10 ^ n

F = fraction expression, default 6 digits precision

G = gerneral expression, somehow smart to show the number in a concise way
[2]
%g is a format specifier used in the C language like %d , %c and so on.

%g gives the result in either %f ( Floating point ) or %e ( Scientific 
notation ) depending upon which one is short.

[3]
They are both examples of floating point input/output.

%g and %G are simplifiers of the scientific notation floats %e and %E.

%g will take a number that could be represented as %f (a simple float or 
double) or %e (scientific notation) and return it as the shorter of the two.

The output of your print statement will depend on the value of sum.

 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
3+4 =