Pointers Questions and Answers
Practice ModeShowing 10 of 217 questions
Q81
char ptrl [ ] = "Drama Actor ";
char *ptr2 = malloc ( 5 );
ptr2 = ptrl;
What is wrong with the above code (assuming the call to malloc does not fail )?
Answer: Option A
Q82
char echo [ 50 ] = "Brain Power";
char *ptr = echo + 5;
From the sample above, which would be the proper way to copy 20 bytes from the location pointted to by ptr to the beginning of echo ?
Answer: Option D
Q83
char sub1 [ 100] = "tamil";
char sub2 [100] = "Hindi";
char *strptrl = sub1 + 2;
char *strptr2=sub2 + 3;
strcpy (strptrl, sub2 );
strcpy ( strptr2, sub1 );
printf ("%s\n", sub1 );
printf ( "%s\n", sub2 );
Given the sample code above, which of the following string values will be printed when the code is executed ?
Answer: Option D
Q84
Scrutinize the following code in C.
char fruit [ ] = "Orange";
char *ptr:
ptr = fruit;
What will be the output for the following expression ?
printf ("%c", * (ptr + 2 ));
Answer: Option B
Q85
In the given code:
int a[50];
int *ptr;
ptr = a;
To access the 7th element of the array which of the following is incorrect ?
Answer: Option D
Q86
main ( )
{
int a [5] = {-2, -1, 3, 4, 5};
int *b;
b = &a [ 2];
Then the value of b[-1] is;
Answer: Option C
Q87
main ()
{
int a = 5, *ptr; ptr = &a;
printf ("%d", ++*ptr);
}
The output might be:
Answer: Option A
Q88
int x, array [10];
From the sample above, which o the following is not a valid initialization for ptr?
Answer: Option A
Q89
int Y[4] = {5, 6, 7, 8};
Which of the following will declare a pointer variable that points to the array in the sample code above ?
Answer: Option C
Q90
int x [ ] = {1, 2, 3, 4, 5};
inr *pre, **ptr2;
ptr = x;
ptr2 = &ptr;
Refering to the sample code above, how would you update x[2] to 10 using ptr2?
Answer: Option C