Reads in a floating-point number and prints it first in decimal-point notation and then in exponential notation. - C Data Type

C examples for Data Type:float

Introduction

Have the output use the following formats:

  • The input is 21.3 or 2.1e+001.
  • The input is +21.290 or 2.129E+001.

Demo Code

#include <stdio.h>

int main(void)
{
  float num;//from w  w w.  j  a va2 s .  c  om

  printf("Enter a number: ");
  scanf("%f", &num);
  printf("The input is %.1f or %.1e\n", num, num);
  printf("The input is %+.3f or %.3E\n", num, num);

  return 0;
}

Result


Related Tutorials