Solution for Exercise 18-14

ex1814

#include <stdio.h>

int main()
{
    int age;
    float weight;
    int *a;
    float *w;

    a = &age;                /* initialize the pointers */
    w = &weight;

    *a = 39;                 /* set the values using */
    *w = 83.9;               /*  the pointers */

    printf("You are %d years old ",age);
    printf("and you weigh %.1f kilos.\n",weight);

    return(0);
}

Output

You are 39 years old and you weigh 83.9 kilos.

Notes

* The values you set for the age and weight, of course, match your own imagination.