Sail E0 Webinar

MCQs

Total Questions : 27 | Page 2 of 3 pages
Question 11. The operator > and
  1.    The pointers point to data of similar type.
  2.    The pointers point to structure of similar data type.
  3.    The pointers point to elements of the same array.
  4.    None of these.
 Discuss Question
Answer: Option C. -> The pointers point to elements of the same array.
Question 12. The declaration
int (*p) [5];
means
  1.    p is one dimensional array of size 5, of pointers to integers.
  2.    p is a pointer to a 5 elements integer array.
  3.    The same as int *p[
  4.    None of these.
 Discuss Question
Answer: Option B. -> p is a pointer to a 5 elements integer array.
Question 13. Comment on the following?
const int *ptr;
  1.    We cannot change the value pointed by ptr.
  2.    We cannot change the pointer ptr itself.
  3.    Both of the above
  4.    We can change the pointer as well as the value pointed by it.
 Discuss Question
Answer: Option A. -> We cannot change the value pointed by ptr.
Question 14. #include
void main()
{
int *ptr, a=10;
ptr = &a;
*ptr += 1;
printf("%d, %d", *ptr, a);
}
  1.    10, 10
  2.    10, 11
  3.    11, 10
  4.    11, 11
 Discuss Question
Answer: Option D. -> 11, 11
Question 15. A function 'p' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as
  1.    int(*p(char *))[]
  2.    int *p(char *)[]
  3.    int (*p) (char *)[]
  4.    None of these.
 Discuss Question
Answer: Option A. -> int(*p(char *))[]
Question 16. What will be printed after compiling and running the following code?
main()
{
char *p;
printf("%d %d",sizeof(*p), sizeof(p));
}
  1.    1 1
  2.    1 2
  3.    2 1
  4.    2 2
 Discuss Question
Answer: Option B. -> 1 2
Question 17. What will be the output of the following program code?
#include
void main()
{
int i=3, *j, **k;
j = &i;
k = &j;
printf("%d%d%d", *j, **k, *(*k));
}
  1.    444
  2.    000
  3.    333
  4.    433
  5.    Garbage Value
 Discuss Question
Answer: Option C. -> 333
Question 18. Which of the following is the correct way of declaring a float pointer:
  1.    float ptr;
  2.    float *ptr;
  3.    *float ptr;
  4.    None of the above
 Discuss Question
Answer: Option B. -> float *ptr;
Question 19. Find the output of the following program.
void main()
{
char *msg = "hi";
printf(msg);
}
  1.    hi
  2.    h
  3.    hi followed by garbage value
  4.    Error
  5.    Garbage Value
 Discuss Question
Answer: Option A. -> hi
Question 20. Find the output of the following program.
void main()
{
int array[10];
int *i = &array[2], *j = &array[5];
int diff = j-i;
printf("%d", diff);
}
  1.    3
  2.    6
  3.    Garbage value
  4.    Error
 Discuss Question
Answer: Option A. -> 3

Latest Videos

Latest Test Papers