Why we use inclusive lower bond and exclusive upper bond for array?
confused?
i.e why we see this syntax
int a[10];
for(i=0;i<10;i++)
instead of
int a[10];
for(i=0;i<=9;i++)
Being faithful to your inner soul, If you don't know the answer, join our site and subscribe for latest updates.
And don't forget to ask the answer of this question.
confused?
i.e why we see this syntax
int a[10];
for(i=0;i<10;i++)
instead of
int a[10];
for(i=0;i<=9;i++)
Being faithful to your inner soul, If you don't know the answer, join our site and subscribe for latest updates.
And don't forget to ask the answer of this question.
int a[10];
for(i=0;i<10;i++)
uses single comparison
int a[10];
for(i=0;i<=9;i++)
uses double comparison
Not exactly!!!!!
This is not the reason!!
i can`t get your question.
but anyway both inputs 10 values and stores in the array.
See buddy in first example it is i<10 and in 2nd i<=9
in most of the books u'll find the syntax in 1st format but in 2nd what is the reason for that?
according to me in books its written i<10 to show the students the size is 10 and the array starts from 0... so array have 10 elements..i dont think there is any huge concept behind that...
Ya you are right partially.
i=1,i<=9,i++
for eg. if there is a string having 70 characters.
if we take a substring starting from 9 and ending at 29.
Then one could guess it has 20 characters. but actually it has 21 characters.
That's why it is a standard to include lower index and exclude upper index.
Hope you got what I am trying to say. :)
ya ...actually i was saying the same but couldnt explain much clearly as u did...
Its ok buddy.
but anyways well attempt!!
Interviewer asks such type of questions!!