closepop
closepop

Would you like to submit the test?


C Language :

Arrays




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

The element will be set to 0.
The compiler would report an error.
The program may crash if some important data gets overwritten
The array size would appropriately grow.




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

ptr is array of pointers to 10 integers
ptr is a pointer to an array of 10 integers
ptr is an array of 10 integers
ptr is an pointer to array




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

Value of elements in array
First element of the array
Base address of the array
Address of the last element of array




4.
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;
}

6,7,8
4,5,6
3,2,15
2,3,4




5.
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;
}

0.1.2.3
1,2,3,4
1,3,4,5
1,4,5,6




6.
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);
}

1
2
3
4




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;
}

65480,65490
65480,65496
65480,65499
65480,65489




8.
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;
}

1,2,3
garbage value 1,2,3,4
1,2,3,4,5
1,4,5




9.
What will be the output of the program ?

#include<stdio.h>

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

1
10
3
4




10.
   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;
}

5
4
7
8




11.
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;
}

1300,1200,1500
1200,1200,1200
1300,1400,1500
1200,1200,1300




12.
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.

1,2
1,4
1,5
1,6




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

In the first statement 6 specifies a particular element, whereas in the second statement it specifies a type
In the first statement 6 specifies a array size, whereas in the second statement it specifies a particular element of array.
In the first statement 6 specifies a particular element, whereas in the second statement it specifies a array size.
In both the statement 6 specifies array size.










FreshersLive - No.1 Job site in India. Here you can find latest 2016 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.


FreshersLive - No.1 Job site in India. Here you can find latest 2016 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.