problem:
Discussed printf () in +%. 2f and both .2% Degree of "+" differences, i.e.,
printf("%+.2f",x);
printf("%.2f",x);
Code:
int main()
{
double a=0.004;
double b=0.005;
double c=-0.004;
double d=-0.005;
printf("a=%.2f b=%.2f c=%.2f d=%.2f\n",a,b,c,d);
printf("a=%+.2f b=%+.2f c=%+.2f d=%+.2f\n",a,b,c,d);
return 0;
}
result:
analysis:
If the number is positive, i.e. the output of the +
If the number is negative, i.e., the output of the first - and then outputs the absolute value of number