why array index always strats wuth zero?
Answers were Sorted based on User's Feedback
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 |
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 |
main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }
main() { clrscr(); } clrscr();
#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }
to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD output should of SAD
# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }
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.
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().
Is the following code legal? struct a { int x; struct a *b; }
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }
Is this code legal? int *ptr; ptr = (int *) 0x400;