home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list11_2.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  905b  |  35 lines

  1.  /* Demonstrates a structure that has array members. */
  2.  
  3.  #include <stdio.h>
  4.  
  5.  /* Define and declare a structure to hold the data. */
  6.  /* It contains one float variable and two char arrays. */
  7.  
  8.  struct data{
  9.      float amount;
  10.      char fname[30];
  11.      char lname[30];
  12.  } rec;
  13.  
  14.  main()
  15.  {
  16.      /* Input the data from the keyboard. */
  17.  
  18.      printf("Enter the donor's first and last names,\n");
  19.      printf("separated by a space: ");
  20.      scanf("%s %s", rec.fname, rec.lname);
  21.  
  22.      printf("\nEnter the donation amount: ");
  23.      scanf("%f", &rec.amount);
  24.  
  25.      /* Display the information. */
  26.      /* Note: %.2f specifies a floating point value */
  27.      /* to be displayed with two digits to the right */
  28.      /* of the decimal point. */
  29.  
  30.      /* Display the data on the screen. */
  31.  
  32.      printf("\nDonor %s %s gave $%.2f.", rec.fname, rec.lname,
  33.              rec.amount);
  34.  }
  35.