wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

unit3 pointers

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

1. Prior to using a pointer variable it should be

a)

Declared

b)

Initialized

c)

Both declared and initialized

d)

None of these

2.

Consider the declaration:

char x[]="WHATIZIT";

char *y="WHATIZIT";

The output of puts(x) an puts(y) will be

a)

Will be the same

b)

Different

c)

Not related

d)

Error

3.

What do the following declaration signify?


char *arr[10];

a)

arr is a array of 10 character pointers.

b)

arr is a array of function pointer.

c)

arr is a array of characters.

d)

arr is a pointer to array of characters.

4.

What is the output of C Program.?

int main()

{

char grade[] = {'A','B','C'};

printf("GRADE=%c, ", *grade);

printf("GRADE=%d", grade);

}

a)

GRADE=some address of array, GRADE=A

b)

GRADE=A, GRADE=some address of array

c)

GRADE=A, GRADE=A

d)

Compiler error

5.

What is the output of C program.?

int main()

{

char grade[] = {'A','B','C'};

printf("GRADE=%d, ", *grade);

printf("GRADE=%d", grade[0]);

}

a)

A A

b)

65 A

c)

65 65

d)

None of the above

6.

What is the output of C program with arrays and pointers.?

int main()

{

int a[3] = {20,30,40};

printf("%d", *(a+1));

}

a)

20

b)

30

c)

40

d)

Compiler error

7.

What is the output of C program with arrays and pointers.?

int main()

{

int size=4;

int a[size];

a[0]=5;

a[1]=6;

a[2]=7;

a[3]=8;

printf("%d %d", *(a+2), a[1]);

}

a)

8 6

b)

7 6

c)

6 6

d)

Compiler error

8.

What is the output of following program?

# include <stdio.h>

void fun(int x)

{

x = 30;

}

int main()

{

int y = 20;

fun(y);

printf("%d", y);

return 0;

}

a)

30

b)

20

c)

Compiler Error

d)

Runtime Error

9.

Output of following program?

# include <stdio.h>

void fun(int *ptr)

{

*ptr = 30;

}

int main()

{

int y = 20;

fun(&y);

printf("%d", y);

return 0;

}

a)

20

b)

30

c)

Compiler Error

d)

Runtime Error

10.

If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?

a)

.

b)

&

c)

*

d)

->