#include #include int main() { typedef struct { char *name; /* name of the planet */ double factor; /* how many times stronger its gravity is than earth's */ } planet_t; planet_t a[] = { {"Mercury", .27}, {"Venus", .85}, {"Earth", 1.00}, {"Mars", .38}, {"Jupiter", 2.33}, {"Saturn", .92}, {"Uranus", .85}, {"Neptune", 1.12}, {"Pluto", .44}, {NULL, 0.00} /* dummy to terminate the array */ }; double weight; int i; planet_t *p; printf("Please type your weight: "); scanf("%lf", &weight); printf("On each planet, your weight would be\n"); for (i = 0; a[i].name != NULL; ++i) { printf("%-11s %6.2f\n", a[i].name, weight * a[i].factor); } for (p = a; p->name != NULL; ++p) { printf("%-11s %6.2f\n", p->name, weight * p->factor); } return EXIT_SUCCESS; }