TCS
Company
Programming
Arrays
What will happen if in a C program you assign a value to an array element
whose subscript exceeds the size of array?
1. The element will be set to 0.
2. The compiler would report an error.
3. The program may crash if some important data gets overwritten.
4. The array size would appropriately grow.
Read Solution (Total 11)
-
- option 3 is correct.
- 6 years agoHelpfull: Yes(3) No(0)
- ans :3
but,it's depends on the compiler .
int arr[2];
arr[3]=10;
printf("%d",arr[3]);
return 0; - 6 years agoHelpfull: Yes(2) No(0)
- option 2: The system would appropriately report an error;
- 6 years agoHelpfull: Yes(1) No(4)
- the element would be set to zero option 1
#include
int main()
{
int a[5]={1,2,3,4};int i;
printf("%d",a[6]);
return 0;
}
output : 0 - 5 years agoHelpfull: Yes(1) No(0)
- anyone can plz tell me the corect answer i will get confusing
- 5 years agoHelpfull: Yes(1) No(0)
- option 1 is correct .
- 5 years agoHelpfull: Yes(1) No(0)
- 3,compiler don,t check bound checking
- 6 years agoHelpfull: Yes(0) No(1)
- 2,since its error
- 6 years agoHelpfull: Yes(0) No(2)
- 3 is correct
- 6 years agoHelpfull: Yes(0) No(0)
- Don't know about other compiler ,but in turbo c++ ,the element will set to 0(option1 is correct)
- 5 years agoHelpfull: Yes(0) No(0)
- option 1 is correct compiler don't check for bound of array it will display default value.
- 5 years agoHelpfull: Yes(0) No(0)
TCS Other Question