C pointer MCQ
Q1. What is the base data type of a pointer variable by which the memory would be allocated to it?
- int
- float
- No datatype
- Depends upon the type of the variable to which it is pointin
- unsigned int
Answer:- (E).
Explanations :None
Explanations :None
- Declared
- Initialized
- Both declared and initalized
- None of these
Answer:- (C).
Explanations :Using a pointer variable, without initializing it, will be disastrous, as it will have a garbage value.
Explanations :Using a pointer variable, without initializing it, will be disastrous, as it will have a garbage value.
- int p*;
- int *p;
- int +p;
- int $p;
Answer:- (B).
Explanations :None.
Explanations :None.
- Passed to a function
- Changed within a function
- Returned by a function
- Can be assigned an integer value
Answer:- (C).
Explanations :None.
Explanations :None.
void main() { int a[] = {1,2,3,4,5}, *p; p = a; ++*p; printf("%d ", *p); p += 2; printf("%d ", *p); }
- 24
- 34
- 22
- 23
Answer:- (BB).
Explanations :none.
Explanations :none.
char *ptr; char mystring[] = "abcdefg"; ptr = myString; ptr += 5;
- fg
- efg
- defg
- bcdefg
Answer:- (A).
Explanations :none.
Explanations :none.
int main() { char str[5] = "LetsFind"; return 0; }
- True
- False
Answer:- (A).
Explanations :C doesn't do array bounds checking at compile time, hence this compiles.But, the modern compilers like Turbo C++ detects this as 'Error: Too many initializers'.GCC would give you a warning.
Explanations :C doesn't do array bounds checking at compile time, hence this compiles.But, the modern compilers like Turbo C++ detects this as 'Error: Too many initializers'.GCC would give you a warning.
- Truer
- Falser
Answer:- (B).
Explanations :none.
Explanations :none.
char ****k;
- k is a pointer to a pointer to a pointer to a char
- k is a pointer to a pointer to a pointer to a pointer to a char
- k is a pointer to a char pointer
- k is a pointer to a pointer to a char
Answer:- (B).
Explanations :k is a pointer to a pointer to a pointer to a pointer to a char.
Explanations :k is a pointer to a pointer to a pointer to a pointer to a char.
char *p = 0; char *t = NULL;
- Yes
- No
Answer:- (B).
Explanations :NULL is #defined as 0 in the 'stdio.h' file. Thus, both p and t are NULL pointers.
Explanations :NULL is #defined as 0 in the 'stdio.h' file. Thus, both p and t are NULL pointers.
Copyright © 2022 Shineskill Software Pvt. Ltd., All rights reserved.