C Language - Arrays

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

 
31.

Which of the following statements are correct about the program below?

#include
int main()
{
int size, i;
scanf("%d", &size);
int arr[size];
for(i=1; i<=size; i++)
{
scanf("%d", arr[i]);
printf("%d", arr[i]);
}
return 0;
}

A. The code is erroneous since the subscript for array used in for loop is in the range 1 to size. B. The code is erroneous since the values of array are getting scanned through the loop.
C. The code is erroneous since the statement declaring array is invalid. D. The code is correct and runs successfully.




32.

What is the output of this program?

#include
using namespace std;
int main()
{
int a = 5, b = 10, c = 15;
int arr[3] = {&a, &b, &c};
cout << *arr[*arr[1] - 8];
return 0;
}

A. 15 B. 18
C. garbage value D. compile time error




33.

What is the output of this program?

#include
using namespace std;
int main()
{
char str[5] = "ABC";
cout << str[3];
cout << str;
return 0;
}

A. ABC B. ABCD
C. AB D. None of the mentioned




34.

int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does testarray[2][1][0] in the sample code above contain?

A. 11 B. 7
C. 5 D. 9




35.

What is the output of this program?

#include
using namespace std;
int main()
{
int array[] = {10, 20, 30};
cout << -2[array];
return 0;
}

A. -15 B. -30
C. compile time error D. garbage value




36.

An array a[8] will store how many values ?

A. 7 B. 8
C. 9 D. 0




« previous

1

2

3

4

5

6

7

8

9

...

next »

 
 
 



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