-
Notifications
You must be signed in to change notification settings - Fork 17
/
question and solution of C++ including pointers.
63 lines (42 loc) · 1.29 KB
/
question and solution of C++ including pointers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
1.
What does the following statement mean?
int (*fp)(char*)
A. pointer to a pointer
B. pointer to an array of chars
C. pointer to function taking a char* argument and returns an int
D. function taking a char* argument and returning a pointer to int
Answer: Option C
Explanation:
pointer to function taking a char* argument and returns an int
2. The operator used for dereferencing or indirection is ____
A. *
B. &
C. ->
D. ->>
Answer: Option A
3.
Choose the right option
string* x, y;
A. x is a pointer to a string, y is a string
B. y is a pointer to a string, x is a string
C. both x and y are pointer to string types
D. none of the mentioned
Answer: Option A
Explanation:
* is to be grouped with the variables not the data types.
4. Which one of the following is not a possible state for a pointer?
A. hold the address of the specific object
B. point one past the end of an object
C. zero
D. point to a tye
Answer: Option D
Explanation:
A pointer can be in only 3 states a,b and c.
5. Which of the following is illegal?
A. int *ip;
B. string s, *sp = 0;
C. int i; double* dp = &i;
D. int *pi = 0;
Answer: Option C
Explanation:
dp is initialized int value of i.