C Programming

prev next

Practise Exercise 10: Pointers

1. Declare a pointer to an integer called address.

int address;
address *int;
int *address;
*int address;

2. Assign the address of a float variable balance to the float pointer temp.

temp = &balance;
balance = float temp;
float temp *balance;
&temp = balance;

3. Assign the character value 'W' to the variable pointed to by the char pointer letter.

'W' = *letter;
letter = "W";
letter = *W;
*letter = 'W';

4. What is the output of the following program segment?


	int  count = 10, *temp, sum = 0;

	temp = &count;
	*temp = 20;
	temp = ∑
	*temp = count;
	printf("count = %d, *temp = %d, sum = %d\n", count, *temp, sum );

count = 2, *temp = 10, sum = 10
count = 20, *temp = 20, sum = 20
count = 10, *temp = 2, sum = 10
count = 200, *temp = 0.2, sum = 1

5. Declare a pointer to the text string "Hello" called message.

char message = "Hello";
*message = "Hello";
char *message = "Hello";
char message = 'Hello';

©Copyright B Brown. 1984-1999. All rights reserved.
prev next