1)Which of the following is the proper declaration of a pointer? a) int p; b) in
ID: 3603085 • Letter: 1
Question
1)Which of the following is the proper declaration of a pointer?
a) int p;
b) int &p;
c) ptr p;
d) int *p;
2)Which of the following gives the memory address of integer variable x?
a) *x
b) x
c) &x
d) address (x)
3)What is wrong with these statements: int *ptr; * ptr = 5;
a) A pointer can not pont to a type of integer
b) *ptr = 5; is not the right way to reference a pointer to update the value it is pointing to
c) A pointer must be initialized to a valid address before referencing it
d) There is nothing wrong with these statements, they will execute fine with no issues
4)Which of the following provides the value stored at the address pointed to by the pointer called ptr?
a) ptr
b)value (ptr)
c) * ptr
d) &ptr
5)Which statement declares and initializes a pointer to an address of a character?
a) char char_ptr = &c;
b) char *char_ptr = &c;
c) both a and b
d) none of the above
6)When precedence is applied, which is an equivalent statement to: i2 = *p1 / 2 + 10;
a) i2 = ((*p1) / 2 ) + 10;
b) i2 = (p1 * 2 ) + 10;
c) i2 = (*p1) / ( 2 + 10);
d) none of the above
7)Which is a valid way to to reference a member called id_number of a structure using a pointer to a structure variable named emp_ptr?
a) (*emp_ptr).id_number = 98401;
b) emp_ptr -> id_number = 98401;
c) Both a and b
d) none of the above
8)C has a specific pointer type, such as: pointer int_ptr;
a) True
b) False
9)A properly declared pointer in C can reference any element of an array, assuming the pointer is declared to point to same type as the array type
a) True
b) False
10)A pointer is passed by value to a function
a) True
b) False
a) int p;
b) int &p;
c) ptr p;
d) int *p;
Explanation / Answer
D, c, d, c, b, a, a, b
1. Answer: D
Explanation:
int *p is the valid declaration for a pointer *p;
2. Answer: C
Explanation:
& Operator fetches the address of a variable. So C is the answer.
3. Answer: D
Explanation:
int *ptr; // declaration of a pointer
* ptr = 5; // declaration of its value
Therefore there is no error with these instructions
4. Answer: C
Explanation:
ptr is the pointer it has address, let ptr = 100 and in the address location 100 value 10 is stored, *ptr fetches 10.
5. Answer: B
Explanation:
char *char_ptr = &c;
c is the char variable; &c is its address location, *char_ptr is the pointer.
6. Answer: A
Explanation:
i2 = ((*p1) / 2 ) + 10; functions same as i2 = *p1 / 2 + 10;
7. Answer: A
Explanation: A is the only valid statement for the given statement.
8. Answer: B
Explanation: In C there is no specific data type called pointer. Pointer is just a address location for a variable.
9. Answer: True
Explanation: pointer are mainly used for this purposel(Calling an array for the function).
10. Answer: False
Explanation: A pointer is always passed by address not the value to a function.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.