C Language - Arrays

You Are Here :: Home > C Language > Arrays - General Questions

 
49.

main()

{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}

A. Hello B. Hello World
C. 0 D. Compiler Error




50.

Which of the following correctly initializes an array arr to contain four elements each with value 0?

I int [] arr = {0, 0, 0, 0};
II int [] arr = new int [4];
III int [] arr = new int [4];
for (int i = 0; i < arr. length; i ++)
arr [i] = 0;

A. I only B. III only
C. II and III only D. I, II, and III




51.

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

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

A. 1200, 1202, 1204 B. 1200, 1200, 1200
C. 1200, 1204, 1208 D. 1200, 1202, 1200




52.

the following program segment is intended to find the index of the first negative integer in arr [0] ... arr [ N-1], where arr is an array of N integers.

int i = 0;
while (arr [i] >= 0)
{
i++;
}
location = i ;
This segment will work as intended

A. Always B. Never
C. Whenever arr contains at least one negative integer D. Whenever arr contains at least one nonnegative integer




53.

What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?

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

A. 65474, 65476 B. 65480, 65496
C. 65480, 65488 D. 65474, 65488




54.

Refer to the following code segment. You may asume that arr is an array of integers.

int sum = arr [0], i = 0;
while (i < arr. length)
{
i++;
sum+= arr [i];
}
Which of the following will be the resul of executing the segment?

A. Sum of arr [0]. arr[1],..., arr [arr.length-1] will be stored in sum B. Sum of arr [1], arr[2],..., arr [arr.length-1] will be stored in sum
C. Sum of arr [0], arr[1],..., arr [arr.length] will be stored in sum D. A run-time error will occur




« previous

1

2

3

4

5

6

8

9

...

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on