Select chapter



functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
linked lists (3.papers)
trees (1.papers)
basics (5.papers)
Hide

Sponsored Links


  

c arrays interview questions and answers

Show Answer
Share Facebook gmail Twitter
2
What are the properties of an Array, in C language?
  1. Array
    -can hold elements of only homogeneous data type
    -is sequentially located cells 
    -accessing data will be faster compared to a linked list
    -inserting a new value, or deleting a old value is time  taking compared to linked list
    -updating an element is faster compared to linked list
  2. Array
    -can hold elements of only heterogeneous data type
    -is sequentially located cells 
    -accessing will be slower compared to a linked list
    -inserting a new value, or deleting a old value is time  taking compared to linked list
    -updating an element is faster compared to linked list
  3. "Array
    -can hold elements of only heterogeneous data type
    -is sequentially located cells 
    -accessing will be faster compared to a linked list
    -inserting a new value, or deleting a old value is less time  taking compared to linked list
    -updating an element is faster compared to linked list"
  4. none of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
7
What is the output of below C program?

#include <stdio.h>
main()
{ 
    int arr[]={1,2,3};
    printf("%p,%p,%p", arr, &arr, &arr[0]); 
}
  1. it is printing address, base address, and 0th location address of array. all the three will be same.
  2. arr, &arr prints same address and &arr[0] prints different address.
  3. arr, and &arr[0] prints same address and &arr prints different address.
  4. &arr[0] and &arr prints same address, and arr prints different address.
Show Answer
Share Facebook gmail Twitter
8
Which of the below statements is true about arrays memory allocation in c language?
  1. arrays that are allocated dynamically will not be stored in contiguous memory locations.
  2. arrays allocated dynamically will be garbage collected automatically.
  3. c will allocate contiguous memory locations to arrays.
  4. When we pass array name to a function, a new array will be created after being passed.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
11
Sample demo code for using sizeof function in C language:
what is the output of below program?

#include <stdio.h>

main()
{
int arr[] = {1,2,3,4,5};
int len = sizeof(arr)/sizeof(int);
for(int i=len-1; i>=0; i--)
 printf("%d",arr[i]);
}
  1. 54321. it is printing array in reverse order.
  2. It crashes the program after printing 54321
  3. it gives compile time error at len=sizeof(arr)/sizeof(int) .. sizeof cant be applicable on primitive data types.
  4. 4321. it prints array in reverse order.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
14
Example code for returning character array from a method in C:
what is the o/p of this below c program?

char *myfunction(int n)
{
char buffer[20];
sprintf(buffer, "%d", n);
return retbuf; 
}
  1. it returns the integer passed to that function, in the form of a string.
  2. We can't return local array to other functions. Output can't be predictable.
  3. it gives compile time error, as we are trying to convert integer to string using some illegal function.
  4. it crashes at run time, as we are trying to convert integer to string using some illegal function.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :