Pointers Questions and Answers
Practice ModeShowing 10 of 217 questions
Q91
main ( )
{
char x [25], y[25], *p = y;
strcpy (x, "BIRTHDAY");
strcpy (y, "HAPPY");
p=x;
strcpy (x, "Lover");
*p = 'd';
printf("p=%s\n", p);
}
What will be the output when the sample code above is executed ?
Answer: Option C
Q92
int *x;x = (int *) 15;
Is the above code legal?
Answer: Option D
Q93
Which statement correctly defines a character string with a length of 4 plus 1 for the terminating NUL?
Answer: Option D
Q94
Given that a is an arrray of elements of type t, val is a 1value expression of type "pointer to t" that points to elements in a then * ++val.
Answer: Option B
Q95
int Y[4] = {6, y, 8, 9};
int *ptr= Y +2;
printf ("%d\n", ptrl[1]);
What is printed when the sample code above is executed ?
Answer: Option C
Q96
printf ("%s\n", string);
Which of the following initializations for the string variable will cause the code above to print the string "First grade actor" when executed without memory leads or memory overwrite ?
Answer: Option A
Q97
# include <ctype.h>
char s [ ] = "Photo Flash";
char *ptr = s;
Referring to the code above, which of the following code is the best way to convert the string s to all lower case letters?
Answer: Option D
Q98
exern void *ptr1;
extern void *ptr2;
int compare ( int n )
{
return ????;
}
What should replace the ???? in the code above to compare the first n bytes of the memory pointed to by ptrl and ptr2 and return a non-zero value if they are equal ?
Answer: Option D
Q99
What memory function should be used to allocate memory in which all bits are initialized to 0 ?
Answer: Option A
Q100
What is the primary differrence between the maolloc and calloc functions ?
Answer: Option C