home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / EXAMPLES.ZIP / INTRO30.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  522 b   |  27 lines

  1. /* INTRO30.C--Example from Chapter 4 of Getting Started */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. typedef struct {
  7.    char name[10];
  8.    float distance;
  9.    float radius;
  10. } planet;
  11.  
  12. planet mars;
  13.  
  14. int main()
  15. {
  16.    strcpy(mars.name,"Mars");
  17.    mars.distance = 1.5;
  18.    mars.radius = 0.4;
  19.  
  20.    printf("Planetary statistics:\n");
  21.    printf("Name: %s\n", mars.name);
  22.    printf("Distance from Sun in AU: %4.2f\n", mars.distance);
  23.    printf("Radius in Earth radii: %4.2f\n", mars.radius);
  24.  
  25.    return 0;
  26. }
  27.