Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? ?->(Show Answer!)
1. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.00 pm
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. Example: Run the below program, it will crash in Windows (TurboC Compiler) #include<stdio.h> int main() { int arr[2]; arr[3]=10; printf("%d",arr[3]); return 0; } Since C is a compiler dependent language, it may give different outputs at different platforms. We have given the Turbo-C Compiler (Windows) output. Please try the above programs in Windows (Turbo-C Compiler) and Linux (GCC Compiler), you will understand the difference better.