GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Dumped Core in Basic Problem 2

Here's my code: 

int a[203];
int main(){
    int t,i;
    for(i = 0;i<t;i++){
        int n,temp,k;
        for(k =0;k<n;k++){
        for(k =0;k<203;k++){
            if(a[k]%2 !=0)

Also, is there any way I can get the code to run in C99 mode?


asked Jan 6, 2017 by Mayank Sharma 10

1 Answer

ur inputs in temp


for this program should be 0<=temp<=202, because you are using it as an index at 


so any illegal/invalid index can cause segmentation fault/core dump because if you give temp>=203, you are trying to access/change the memory location which is not valid under the range of array "a[203]"

answered Jan 8, 2017 by imlegion