why array index always strats wuth zero?

Answers were Sorted based on User's Feedback



why array index always strats wuth zero?..

Answer / sameer

it because arrays index are pointers and you are giving
offsets from the base pointer & base pointer is starting
element address so it has offset zero from base pointer

Is This Answer Correct ?    11 Yes 3 No

why array index always strats wuth zero?..

Answer / surya.raj

Since I found this questions answer on a another website and
I can do copy and paste from there, but in order to make
copyright and royalty of original poster I am not tending to
do that so, here is the link below from where you can get
answer of your question.

http://developeronline.blogspot.com/2008/04/why-array-index-should-start-from-0.html

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


main() { clrscr(); } clrscr();

2 Answers  


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD output should of SAD

6 Answers   Synergy,


# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  


main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

3 Answers  


1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

8 Answers   IBPS, Infosys, TCS,


int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

2 Answers  


Is the following code legal? struct a { int x; struct a *b; }

2 Answers  


Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.

3 Answers   Wipro,


main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  


Is this code legal? int *ptr; ptr = (int *) 0x400;

1 Answers  


Categories