#include #include char *name[] = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" }; #define N (sizeof name / sizeof name[0]) /* the number of planets */ double factor[] = { /* gravity compared to earth's */ .27, /* Mercury */ .85, /* Venus */ 1.00, /* Earth (by definition) */ .38, /* Mars */ 2.33, /* Jupiter */ .92, /* Saturn */ .85, /* Uranus */ 1.12, /* Neptune */ .44 /* Pluto */ }; int main() { double weight; int i; char **pn; double *pf; printf("Please type your weight: "); scanf("%lf", &weight); printf("On each planet, your weight would be\n"); for (i = 0; i < N; ++i) { printf("%-11s %6.2f\n", name[i], factor[i] * weight); } for (pn = name, pf = factor; pn < name + N; ++pn, ++pf) { printf("%-11s %6.2f\n", *pn, *pf * weight); } return EXIT_SUCCESS; }