Deitel & Deitel, C How to Program 6th Edition, Exercise 9.17 (Outputting a Number with the Floating-Point Conversion Specifiers)

// 9.17 (Outputting a Number with the Floating-Point Conversion Specifiers)

#include <stdio.h>

int main() {
float num;
printf("Input with %%f: ");
scanf("%f", &num);
printf("-printing with %%f: %f\n", num);
printf("-printing with %%e: %e\n", num);
printf("-printing with %%g: %g\n\n", num);

printf("Input with %%e: ");
scanf("%e", &num);
printf("-printing with %%f: %f\n", num);
printf("-printing with %%e: %e\n", num);
printf("-printing with %%g: %g\n\n", num);

printf("Input with %%g: ");
scanf("%g", &num);
printf("-printing with %%f: %f\n", num);
printf("-printing with %%e: %e\n", num);
printf("-printing with %%g: %g\n\n", num);


printf("\n\n\n");
return 0;
}

OUTPUT

Input with %f: 1.2345
-printing with %f: 1.234500
-printing with %e: 1.234500e+00
-printing with %g: 1.2345

Input with %e: 1.2345
-printing with %f: 1.234500
-printing with %e: 1.234500e+00
-printing with %g: 1.2345

Input with %g: 1.2345
-printing with %f: 1.234500
-printing with %e: 1.234500e+00
-printing with %g: 1.2345




Press any key to continue . . .

Comments

Popular posts from this blog

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.23 (Turtle Graphics)

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.22 (Total Sales)

Deitel & Deitel, C How to Program 6th Edition, Exercise 5.47 (Craps Game Modification)