On 10/25/07, 洪海昆 <[EMAIL PROTECTED]> wrote:
> #include<stdio.h>
>  int main()
>  {
>   int a[]={1,2,3};
>   int b[]={4,5,6,7};
>  sum=a[1]+b[1];
>   printf("%d+%d=%d\n",a[1],b[1],sum);
>    return 0;
>  }
>
>  I want to get the result "1+4=5".How to correct the programming?

C and C++ has zero-based arrays, meaning the first element is at index
0, the second at index 1, etc.
This means that to access the 1 and the 4 you need to use a[0] and b[0].

-- 
Tamas Marki

Reply via email to