/* A D D _ P T R
 *
 * Demonstrate declaration and use of pointers.
 *
 */

int
main(void)
{
	int number1, number2, sum;    /* declare variable names */
	int *np1, *np2, *sp;          /* declare pointers       */

	/*
	 * Load pointers with addresses of the declared variables.
	 */
	np1 = &number1;
	np2 = &number2;
	sp = &sum;

	/*
	 * Put values into memory locations pointed to
	 * by the pointers.
	 */
	*np1 = 5;
	*np2 = 7;
	*sp = *np1 + *np2;

	/*
	 * Print out the addresses of the variables
	 * and their contents.
	 */
	printf("\nName\tAddress\tValue\n");
	printf("----\t-------\t-----\n");
	printf("%s\t%d\t%d\n", "number1", &number1, *np1);
	printf("%s\t%d\t%d\n", "number2", &number2, *np2);
	printf("%s\t%d\t%d\n", "sum", &sum, *sp);
	printf("%s\t%d\t%d\n", "*np1", &np1, np1);
	printf("%s\t%d\t%d\n", "*np2", &np2, np2);
	printf("%s\t%d\t%d\n", "*sp", &sp, sp);

	return (0);
}

