C Language - Pointers
You Are Here :: Home > C Language > Pointers - General Questions
13.
Declaration int *(*p) int(*a)(i) is ?
A.
A pointer to a, which returns an integer
B.
A pointer to function that accepts an integer argument and returns an integer
C.
A pointer to subroutine, which returns result of evaluation
D.
None of Above
Answer: Option B
Explanation:
14.
Null pointer and UN-initialized pointers are same ?
A.
False
B.
None of Above
C.
True
D.
Varies from program to program
Answer: Option A
Explanation:
15.
Null pointer is ?
A.
A pointer which does not point anywhere
B.
A pointer that returns 0 values
C.
None of Above
D.
Pointer defined with name Null
Answer: Option A
Explanation:
16.
What are the values of trouble and *pt after the following program fragment has been executed?
double trouble = 13.13;
double *pt;
pt = &trouble;
*pt = 9.9;
A.
trouble is 13.13, *pt is 9.9
B.
trouble is 9.9, *pt is 13.13
C.
trouble is undefined, *pt is 9.9
D.
trouble is 9.9, *pt is 9.9
Answer: Option D
Explanation:
17.
Consider the following program fragment, assuming the
#include directive:
char saying[] = "Too many cooks spoil the broth.";
char *p1, *p2;
p1 = saying;
p2 = saying + 8;
*p2 = '\0';
printf("%s\n", saying);
What string will be printed?
A.
"Too many cooks spoil the broth."
B.
"cooks spoil the broth."
C.
"Too many"
D.
"Too manycooks spoil the broth."
Answer: Option C
Explanation:
18.
main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='\0') ++*p++;
printf("%s %s",p,p1);
}
A.
ibj!jfoetgs
B.
foetibj!gsj
C.
ibj!gsjfoet
D.
ib!gsjfojet
Answer: Option C
Explanation:
++*p++ will be parse in the given order
*p that is value at the location currently pointed by p will be taken ++*p the retrieved value will be incremented.when ; is encountered the location will be incremented that is p++ will be executed
Hence, in the while loop initial value pointed by p is 'h', which is changed to 'i' by executing ++*p and pointer moves to point, 'a' which is similarly changed to 'b' and so on. Similarly blank space is converted to '!'. Thus, we obtain value in p becomes "ibj!gsjfoet" and since p reaches '\0' and p1 points to p thus p1doesnot print anything.
« previous
...
next »