Please answer the question (in terms of C programming) and explain answer End of
ID: 3905929 • Letter: P
Question
Please answer the question (in terms of C programming) and explain answer
End of Semester 1, 2016 COMP1004 Engineering Programming Q4(d) The statement in line 70 of the following program segment (only part of the program is shown) is valid. True or false (1 marks)? 0 int counts [10],i; 20 float x [5] [5] 30 40 printf ("Enter an integer between 0 and 4> ); 50 i-0; 60 scanf ("*d", &counts; (i]) 70 x[counts [1]][counts [1]]-8.384; What will happen if an integer with value greater than 4 is entered when the program is executed (2 marks)? [3 marks] TuurExplanation / Answer
Statement on line 70 is valid.hence true.
If we enter a value greater than 4 we will get an undefined behaviour. The compiler may or may not raise the error or warning. If that memory is not allocated to any other element than this assignment will work, if not then segmentation fault may arise as we trying to access memory which is not allocated to us.