Sail E0 Webinar

MCQs

Total Questions : 34 | Page 3 of 4 pages
Question 21. What is the output of this C code?
void main()
{
int x = 0;
int *ptr = &x;
printf("%p\n", ptr);
ptr++;
printf("%p\n ", ptr);
}
  1.    0xbfd605e8   0xbfd605ec
  2.    0xbfd605e8   0cbfd60520
  3.    0xbfd605e8   0xbfd605e9
  4.    Run time error
 Discuss Question
Answer: Option A. -> 0xbfd605e8   0xbfd605ec


None.


Question 22. What is the output of this C code?
void main()
{
int x = 0;
int *ptr = &x;
printf("%d\n", *ptr);
}
  1.    Address of x
  2.    Junk value
  3.    0
  4.    Run time error
 Discuss Question
Answer: Option C. -> 0


None.


Question 23. What is the output of this C code?
void main()
{
int x = 0;
int *ptr = &5;
printf("%p\n", ptr);
}
  1.    5
  2.    Address of 5
  3.    Nothing
  4.    Compile time error
 Discuss Question
Answer: Option D. -> Compile time error


None.


Question 24. What is the output of this C code?
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);
}
void foo(int *p)
{
printf("%d\n", *p);
}
  1.    10
  2.    Some garbage value
  3.    Compile time error
  4.    Segmentation fault/code crash
 Discuss Question
Answer: Option C. -> Compile time error


None.


Question 25. What is the output of the code below?
int main()
{
int i = 10;
int *const p = &i;
foo(&p);
printf("%d\n", *p);
}
void foo(int **p)
{
int j = 11;
*p = &j;
printf("%d\n", **p);
}
  1.    11   11
  2.    Undefined behaviour
  3.    Compile time error
  4.    Segmentation fault/code-crash
 Discuss Question
Answer: Option A. -> 11   11


None.


Question 26. Which of the following are correct syntaxes to send an array as a parameter to function:
  1.    func(&array);
  2.    func(array);
  3.    func(*array);
  4.    func(array[size]);
 Discuss Question
Answer: Option B. -> func(array);


None.


Question 27. What is the output of this C code?
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **m);
}
  1.    5   5   5
  2.    5  5 junk value
  3.    5 junk value
  4.    Run time error
 Discuss Question
Answer: Option A. -> 5   5   5


None.


Question 28. What is the output of this C code?
int
main()
{
int i = 10;
int *p = &i;
foo(&p);
printf("%d ", *p);
printf("%d ", *p);
}
void foo(int **const p)
{
int j = 11;
*p = &j;
printf("%d ", **p);
}
  1.    11   11   11
  2.    11  11 Undefined-value
  3.    Compile time error
  4.    Segmentation fault/code-crash
 Discuss Question
Answer: Option B. -> 11  11 Undefined-value


None.


Question 29. What is the output of this C code?
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **p);
}
  1.    5  5  5
  2.    5  5 junk value
  3.    5 junk value
  4.    Compile time error
 Discuss Question
Answer: Option D. -> Compile time error


None.


Question 30. What is the output of this C code?
void
main()
{
int k = 5;
int *p = &k;
int **m = &p;
**m = 6;
printf("%d\n", k);
}
  1.    5
  2.    Compile time error
  3.    6
  4.    Junk
 Discuss Question
Answer: Option C. -> 6


None.


Latest Videos

Latest Test Papers