C-Array Questions and Answers

C-Array Questions and Answers
81. In terms of code generation, how do the tweo definitions of buf, both presented below, differ?
char buf [ ]="Hellow World";
char *buf="Hello world!";

  • the first definition certainly allows the contents of but to be safely modified at runtime, the second definition does not.
  • the first definition is not suitable for usage as an argument to a function call; the second definition is.
  • the first definition is not legal because it does not indicate thesize of the array to be allocated. the second definition is legal.
  • The first definition does not allocate enoughl space for a terminating Null character, not does it append one; the seond definition does.
Show Answer
82. Whch of the following is equivalent to *(a[3]+2).

  • a [3] [2]
  • ((*a+3)+2)
  • (*(a+3)+2)
  • None of the above
Show Answer
83. Which of the following creates a single dimensional array equivalent to the dynamic array ?
char x[30];
  • char *const x=(char *const) malloc (30);
  • char *x=(char *) malloc (30);
  • char *x=(const char*) malloc (30);
  • None of the above
Show Answer
84. What is the length of the following string ?
char x[ ] ="8, 9, 10, 11, 12, ";

  • 5
  • 6
  • 8
  • 12
Show Answer
85. Find the output
void main ()
{
int x[ ]={1, 2, 3, 4, 5, 6};
int *p,q,r;
p=x+3;
q=5, r=4;
printf("%d", p[(q>r)-2]);
}

  • 4
  • 3
  • 5
  • Compilation error
Show Answer
86. Find the output.
void main ()
{
int p[4]={15, 25, 35, 45}, *a;
p[-1]=5;
a=p;
printf("%d", -1[++a]);
}

  • -35
  • 25
  • -5
  • Compilation error
Show Answer
87. Find out the output
void main ( )
{
int a[ ]={1, 2, 3, 4, 5, 6};
int *ptr=a+2;
printf("%d %d', --*ptr+1, 1+*--ptr);
}

  • 13
  • 12
  • 23
  • Compilation error
Show Answer
88. Find the output
void main ()
{
char a[ ] =
{'1', '2', '3', 0, '1', '2', '3' };
printf(a);
}

  • 123
  • 123123
  • 1230123
  • Compilation error
Show Answer
89. Find the output
int one_d[ ]={1, 2, 3};
void main ( )
{
int *ptr;
ptr=one_d;
ptr+=-3&2&&-5;
ptintf ("%d", *ptr);
}

  • 1
  • 2
  • 3
  • Compilation error
Show Answer
90. Find the output
{
void main ( )
{
char a[5]="abcd";
int b = 3;
printf("%c\n", a[b]);
printf("%c", ((char*)b) [(int)a]);
}

  • Compilation Error
  • d d
  • d Garbage value
  • None of these
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test