Arrays Questions and Answers updated daily – C Language



13 Arrays Questions and answers section with explanation for various online exam preparation, various interviews, C Language Arrays online test. Arrays Questions with detailed description, explanation will help you to master the topic.

Arrays Questions

1.
Which of the following statements are correct about 6 used in the program?
int num[6];
num[6]=21;



SHOW ANSWER
Correct Ans:In the first statement 6 specifies a array size, whereas in the second statement it specifies a particular element of array.
Explanation:


2.
Which of the following statements are correct about an array?
1: The array int num[26]; can store 26 elements.
2: The expression num[1] designates the very first element in the array.
3: It is necessary to initialize the array at the time of declaration.
4: The declaration num[SIZE] is allowed if SIZE is a macro.



SHOW ANSWER
Correct Ans:1,4
Explanation:


3.
What will be the output of the program if the array begins 1200 in memory?

#include<stdio.h>

int main()
{
    int arr[]={2, 3, 4, 1, 6};
    printf("%u, %u, %un", arr, &arr[0], &arr);
    return 0;
}



SHOW ANSWER
Correct Ans:1200,1200,1200
Explanation:


4.
   What will be the output of the program ?

#include

int main()
{
    float arr[] = {12.4, 2.3, 4.5, 6.7};
    printf("%dn", sizeof(arr)/sizeof(arr[0]));
    return 0;
}



SHOW ANSWER
Correct Ans:4
Explanation:


5.
What will be the output of the program ?

#include<stdio.h>

int main()
{
    int arr[1]={10};
    printf("%dn", 0[arr]);
    return 0;
}



SHOW ANSWER
Correct Ans:10
Explanation:


6.
What will be the output of the program in Turb C (under DOS)?

#include<stdio.h>

int main()
{
    int arr[5], i=0;
    while(i<5)
        arr[i]=++i;

    for(i=0; i<5; i++)
        printf("%d, ", arr[i]);

    return 0;
}



SHOW ANSWER
Correct Ans:garbage value 1,2,3,4
Explanation:


7. What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?
#include<stdio.h>

int main()
{
    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
    printf("%u, %un", a+1, &a+1);
    return 0;
}



SHOW ANSWER
Correct Ans:65480,65496
Explanation:


8.
What will be the output of the program ?

#include<stdio.h>
void fun(int **p);

int main()
{
    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
    int *ptr;
    ptr = &a[0][0];
    fun(&ptr);
    return 0;
}
void fun(int **p)
{
    printf("%dn", **p);
}



SHOW ANSWER
Correct Ans:1
Explanation:


9.
What will be the output of the program ?

#include<stdio.h>

int main()
{
    void fun(int, int[]);
    int arr[] = {1, 2, 3, 4};
    int i;
    fun(4, arr);
    for(i=0; i<4; i++)
        printf("%d,", arr[i]);
    return 0;
}
void fun(int n, int arr[])
{
    int *p=0;
    int i=0;
    while(i++ < n)
        p = &arr[i];
    *p=0;
}



SHOW ANSWER
Correct Ans:1,2,3,4
Explanation:


10.
What will be the output of the program ?

#include<stdio.h>

int main()
{
    int a[5] = {5, 1, 15, 20, 25};
    int i, j, m;
    i = ++a[1];
    j = a[1]++;
    m = a[i++];
    printf("%d, %d, %d", i, j, m);
    return 0;
}



SHOW ANSWER
Correct Ans:3,2,15
Explanation:


11. In C, if you pass an array as an argument to a function, what actually gets passed?



SHOW ANSWER
Correct Ans:Base address of the array
Explanation:
The statement 'C' is correct. When we pass an array as a funtion argument, the base address of the array will be passed.


12.
What does the following declaration mean?
int (*ptr)[10];



SHOW ANSWER
Correct Ans:ptr is a pointer to an array of 10 integers
Explanation:


13. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?



SHOW ANSWER
Correct Ans:The program may crash if some important data gets overwritten
Explanation:



FreshersLive - No.1 Job site in India. Here you can find latest 2017 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.