Variations on Floating-Point Input - C Language Basics

C examples for Language Basics:scanf

Description

Variations on Floating-Point Input

Demo Code

#include <stdio.h>

int main(void)
{
  float fp1 = 0.0f;
  float fp2 = 0.0f;
  float fp3 = 0.0f;
  int value_count = 0;
  printf("Enter: 3.14.314E1.0314e+02\n");

  printf("Input:\n");
  value_count = scanf("%f %f %f", &fp1, &fp2, &fp3);

  printf("\nOutput:\n");
  printf("Number of values read = %d\n", value_count);
  printf("fp1 = %f  fp2 = %f  fp3 = %f\n", fp1, fp2, fp3);
  return 0;/*from w w w  . j a  v a 2  s .  c  o  m*/
}

Related Tutorials