C
Programming and Technical
Programming
Program
What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
Options
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 12)
-
- Answer:3)The program may crash if some important data gets overwritten.
Example consider the following program:
void main()
{
int a[10];
a[15]=65;
printf("%d",&a[15]);
}
when we compile this code we get some garbage value it just simply crash the values,based on the type of compiler the garbage value may vary. - 8 years agoHelpfull: Yes(7) No(0)
- 2: the complier would report an error
- 8 years agoHelpfull: Yes(1) No(0)
- If the index of the array size is exceeded, the program will crash. Hence "option c" is the correct answer. But the modern compilers will take care of this kind of errors.
- 6 years agoHelpfull: Yes(1) No(0)
- it provides a garbage value...probably it ll crash
- 8 years agoHelpfull: Yes(0) No(0)
- the program may crash
- 7 years agoHelpfull: Yes(0) No(0)
- The compiler would report an error
- 7 years agoHelpfull: Yes(0) No(0)
- 1.)The element will be set to 0.
- 7 years agoHelpfull: Yes(0) No(0)
- 3) the program may crash if some important data gets overwritten.
- 7 years agoHelpfull: Yes(0) No(0)
- the program may crash if some important data gets overwritten
- 6 years agoHelpfull: Yes(0) No(0)
- 2 the complier would report an error
- 6 years agoHelpfull: Yes(0) No(0)
- The neighbour memory locations will be accessed and program may be crashed
- 4 years agoHelpfull: Yes(0) No(0)
- 3
3 OPTION IS THE ANS. - 4 years agoHelpfull: Yes(0) No(0)
C Other Question