The greatest mistake you can make in life is to be continually fearing you will make one

Thursday, 9 December 2010

Some Questions about Arrays

  1. How will you define an array?
  2. Is it necessary to specify the storage class in array definition? what is the default storage class for arrays?
  3. If the array elements are not initialized then what is the default initial value?for example: int x[5]; what is the value of x[1]?
  4. Consider we have a 10 element array what happen if we try to access the 12th element?
  5. Can I declare the array without specifying the size? int a[]; is it allowed?
  6. int a[]={1,2,3,4,5}; Is it allowed?
  7. Consider int a[5]={1,2,3,4,5}; printf("a=%d",*a); what is the output?
  8. Consider int a[5]={10,20,30,40,50}; printf("a=%d",a); what is the output?
  9. The last character in a array must be a NULL(\0) character what happen if I missed the '\0' character? char vowels[6]={'a','e','i','o','u'}; Is it correct?
  10. What happen If I am not giving space for '\0' character? char flag[4]={'T','R','U','E'}; is it correct?
  11. What happen If I am not giving space for '\0' character in string? char str[5]="Welco"; is it correct?
  12. x is a array pointer. what is the value for *x++; 
  13. Is there any way to find the size of the array?
  14. Can I print the characters given in single quotes as string?
  15. What is the output for the following program?
    #include<stdio.h>
    int main()
    
    {
    
        char x[]={'a','e','i','o','u'};
    
        printf("ans=%s",x);
        return;
    }
  16. What is the output for the following program?
    #include <stdio.h>
    int main()
    {     int x[5]={10,20,30,40,50};
        printf("ans=%d",(*x)++);
        return;
    }
  17. What is the output for the following program?
    #include <stdio.h>
    int main()
    {
        int x[5]={10,20,30,40,50};
        printf("ans=%d",++*x);
        return;
    }
  18. Do we have any minimum or maximum size restrictions in array index?
  19. What is the maximum index(sixe) number an array can have?
  20. Why array index is starting from zero? (or) Why arrays not store values from 1?
  21. Can I declare an array with 0 size? int a[0]; is it allowed?
  22. Can I declare an array with negative size? int a[-5]; is it allowed?
  23. Can I compare 2 arrays with single operator?
  24. Can I have comma(,) alone in the array list? int x[5]={,,,,}; Is it allowed?
  25. What happen if the array size is less than the number of initialized values?int a[5]={1,2,3,4,5,6,7,8,9,}; is it allowed?
  26. How to pass and access the array values to the function using call by value method?
  27. How to pass and access the array values to the function using call by reference method?
  28. Array name is a pointer. If an array is passed to a function and several of its elements are altered with in the function, are these changes recognized in the calling portion of the program?
  29. Can an array can be passed from a function to the calling portion of the program via return statement?
  30. Is there is any difference in storing 1 dimensional array and multi dimensional array?
  31. How the elements of a 2 dimensional array is stored? row major form (or) column major form?
  32. what is the size of a  2 dimensional array, 3 dimensional array?
  33. In 2 dimensional array number of rows specified first or number of columns specified first?
  34. Is it necessary to specify both  number of rows and number of columns in 2 dimensional array?
  35. Can I leave the number of columns in 2 dimensional array? int a[5][]; is it allowed?
  36. Can I initialize a[][]={1,2,3,4,5,6,7,8,9}; (or) a[5][]={1,2,3,4,5,6,7,8,9}; 
For Answers, Click here

      No comments:

      Post a Comment