554 views
2 votes
2 votes

Ram while writing his C code used char mydata[1000] instead of int mydata[1000]. All the test cases were successful but the code failed during production despite all paths in the program being covered by the test cases. What could be the possible reason?
 

  1. During testing only the first few array elements were tested
  2. During testing all the array elements were same
  3. The array numbers used for testing were small
  4. Size of int and char happened to be same on the test machine

2 Answers

0 votes
0 votes

I had appeared for the test and got it right.

Explanation : Since int size(2 or 4 bytes) is more than size of char, large size numbers can be represented using int. But Ram used char instead of int. So in order for compilation to be successful, the array numbers used for test cases must be small that it didn't get detected. 

–1 votes
–1 votes
(A)..suppose here concept of pointers is applied.suppose int takes 2 Bytes of data(32 bit system) and char takes 1 byte of data .when we have replaced int by char so each location pointed by a pointer was at a gap of 2 initially but after it will be 1...so while testing we will not be able to point each element .some elements will be left nontested .
Answer:

Related questions

1 votes
1 votes
1 answer
3
1 votes
1 votes
1 answer
4