int num[5]; num[5]= ; The 5 in the first and the second statements denotes

This question is related to Wipro Interview

Showing Answers 1 - 6 of 6 Answers

vijay patel

  • Aug 12th, 2005

ans. in 1st statement 5 denotes an array(num)has 6th integer elements. 
in 2nd statement 5 indicates we want to assign 6th element value

  Was this answer useful?  Yes

Annapareddy SrinivasRao

  • Jan 20th, 2006


I think ur wrong

when we are declaring array has some num[5],that means it has the limit to has the 5 elements...

those are num[0],num[1],num[2],num[3],num[4] that's it

in this first one we have to answer like "5" the lenght of that array...

come to second one num[5] in not a region of that array............

so compiler thinks that it is an error and it is raising an exception that Arryindexout of Bound error



  • Jan 30th, 2006

I think when we give an index value that is greater than the decleared size of the array the compiler dosnot give any error or wrning message,and such initialization may lead to overwriting of some other totally depends on the programmer to take care of it that array bounds are not exceeded.

  Was this answer useful?  Yes

Shibu Macfast

  • Feb 15th, 2006

int a[5] will reserve memory for array with size 5. i.e., location num[0], num[1],num[2], num[3]and num[4]; assigning any value to num[5] is possible. But that data may not be secure, that may lost. compiler willnot make any error while compiling. if we didn't specify any value it will display some garbage value.

  Was this answer useful?  Yes


  • Jun 18th, 2006

the first line 5 indicates the array size

the second line merely looking it would denote the sixth element of the array but there arrises an exception that it exceeds the array size so it would be err

  Was this answer useful?  Yes


  • Oct 3rd, 2020

Correct, Array size would appropriately grow!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions