C Array Questions and Answers

Take Exam

Arrays in C language form the foundation of data storage and manipulation. They store multiple values of the same type under a single variable name, allowing efficient data handling. Programming questions and answers related to arrays frequently appear in campus placement exams and coding interviews by TCS, Wipro, and Capgemini. This topic includes C array questions with answers covering array declaration, initialization, multidimensional arrays, and pointer relations. Practicing these problems will enhance your understanding of indexing, memory usage, and algorithm design for real-world applications.

C Array

Showing 10 of 108 questions

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 Report

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 Report

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 Report

84. What is the length of the following string ? char x[ ] ="8, 9, 10, 11, 12, ";

  • 5
  • 6
  • 8
  • 12
Show Answer Report

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 Report

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 Report

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 Report

88. Find the output void main () { char a[ ] = {'1', '2', '3', 0, '1', '2', '3' }; printf(a); }

  • 123
  • 123123
  • 1230123
  • Compilation error
Show Answer Report

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 Report

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 Report
Questions and Answers for Competitive Exams Various Entrance Test