Sail E0 Webinar

MCQs

Total Questions : 27 | Page 1 of 3 pages
Question 1. Determine Output:
void main()
{
char far *farther, *farthest;
printf("%d..%d", sizeof(farther), sizeof(farthest));
}
  1.    4..2
  2.    2..2
  3.    4..4
  4.    2..4
 Discuss Question
Answer: Option A. -> 4..2
Question 2. Determine Output:
main()
{
char *str1 = "abcd";
char str2[] = "abcd";
printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));
}
  1.    2 5 5
  2.    2 4 4
  3.    8 5 5
  4.    2 4 5
 Discuss Question
Answer: Option C. -> 8 5 5
Question 3. Choose the best answer.
Prior to using a pointer variable
  1.    It should be declared.
  2.    It should be initialized.
  3.    It should be both declared and initialized.
  4.    None of these.
 Discuss Question
Answer: Option C. -> It should be both declared and initialized.
Question 4. Comment on the following pointer declaration?
int *ptr, p;
  1.    ptr is a pointer to integer, p is not.
  2.    ptr and p, both are pointers to integer.
  3.    ptr is pointer to integer, p may or may not be.
  4.    ptr and p both are not pointers to integer.
 Discuss Question
Answer: Option A. -> ptr is a pointer to integer, p is not.
Question 5. What will be the output?
main()
{
char *p;
p = "Hello";
printf("%cn",*&*p);
}
  1.    Hello
  2.    H
  3.    Some address will be printed
  4.    None of these.
 Discuss Question
Answer: Option B. -> H
Question 6. Determine output:
#include
void main()
{
char *p = NULL;
char *q = 0;
if(p)
printf(" p ");
else
printf("nullp");
if(q)
printf("q");
else
printf(" nullq");
}
  1.    p q
  2.    Depends on the compiler
  3.    x nullq where x can be p or nullp depending on the value of NULL
  4.    nullp nullq
 Discuss Question
Answer: Option D. -> nullp nullq
Question 7. The address operator &, cannot act on
  1.    R-values
  2.    Arithmetic expressions
  3.    Both of the above
  4.    Local variables
  5.    Members of a structure
 Discuss Question
Answer: Option C. -> Both of the above
Question 8. The statement
int **a;
  1.    is illegal
  2.    is legal but meaningless
  3.    is syntactically and semantically correct
  4.    None of these.
 Discuss Question
Answer: Option C. -> is syntactically and semantically correct
Question 9. What will be the output of the following program code?
#include
void main()
{
int i = 10;
void *p = &i;
printf("%f", *(float *)p);
}
  1.    Error
  2.    10
  3.    0.000000
  4.    None of these.
 Discuss Question
Answer: Option C. -> 0.000000
Question 10. What will be the output of the following program?
#include
void main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
}
  1.    Compiler time error
  2.    Segmentation fault/runtime crash
  3.    10
  4.    Undefined behavior
 Discuss Question
Answer: Option A. -> Compiler time error

Latest Videos

Latest Test Papers