Sail E0 Webinar

MCQs

Total Questions : 86 | Page 5 of 9 pages
Question 41.

What will be the output?    int main()    {        printf("%d", d++);    }    int d = 10;

  1.    9
  2.    10
  3.    11
  4.    Compile time error
 Discuss Question
Answer: Option D. -> Compile time error


None.


Question 42. What is the output of this C code?    double i;    int main()    {       printf("%g\n",i);       return 0;    }
  1.    0
  2.    0.000000
  3.    Garbage value
  4.    Depends on the compiler
 Discuss Question
Answer: Option B. -> 0.000000


None.


Question 43. Which part of the program address space is p stored in the code given below?    int *p;    int main()    {        int i = 0;        p = &i;        return 0;    }
  1.    Code/text segment
  2.    Data segment
  3.    Bss segment
  4.    Stack
 Discuss Question
Answer: Option C. -> Bss segment


None


Question 44. Which part of the program address space is p stored in the code given below?    int *p = NULL;    int main()    {        int i = 0;        p = &i;        return 0;    }
  1.    Code/text segment
  2.    Data segment
  3.    Bss segment
  4.    Stack
 Discuss Question
Answer: Option B. -> Data segment


None.


Question 45. Property of external variable to be accessed by any source file is called by C90 standard as:
  1.    external linkage
  2.    external scope
  3.    global scope
  4.    global linkage
 Discuss Question
Answer: Option A. -> external linkage


None.


Question 46. Can variable i be accessed by functions in another source file?    int i;    int main()    {        printf("%d\n", i);    }
  1.    0
  2.    false
  3.    Only if static keyword is used
  4.    Depends on the type of the variable
 Discuss Question
Answer: Option A. -> 0


None.


Question 47. What is the output of this C code?
int main()
{
void foo(), f();
f();
}
void foo()
{
printf("2 ");
}
void f()
{
printf("1 ");
foo();
}
  1.    Compile time error as foo is local to main
  2.    1   2
  3.    2   1
  4.    Compile time error due to declaration of functions inside main
 Discuss Question
Answer: Option B. -> 1   2


None.


Question 48. What is the output of this C code?
void foo();
int main()
{
void foo();
foo();
return 0;
}
void foo()
{
printf("2 ");
}
  1.    Compile time error
  2.    2
  3.    Depends on the compiler
  4.    Depends on the standard
 Discuss Question
Answer: Option B. -> 2


None.


Question 49. What is the output of this C code?
int main()
{
void foo();
void f()
{
foo();
}
f();
}
void foo()
{
printf("2 ");
}
  1.    2   2
  2.    2
  3.    Compile time error
  4.    Depends on the compiler
 Discuss Question
Answer: Option D. -> Depends on the compiler


Even though the answer is 2, this code will compile fine only with gcc. GNU C supports nesting of functions in C as a language extension where as standard C compiler doesn't.


Question 50. What is the output of this C code?
void foo();
int main()
{
void foo(int);
foo(1);
return 0;
}
void foo(int i)
{
printf("2 ");
}
  1.    2
  2.    Compile time error
  3.    Depends on the compiler
  4.    Depends on the standard
 Discuss Question
Answer: Option A. -> 2


None.


Latest Videos

Latest Test Papers