Hi,you made a common mistake, the first element in an array is [0], not [1], so
if you wanted to get the numbers you need, you should change your printf
express as below:
printf("%d +%d =%d/n", a[0], b[0], sum);
----- Original Message -----
From: 洪海昆
To: [email protected]
Sent: Thursday, October 25, 2007 8:51 PM
Subject: [c-prog] sum about array
#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?
Waiting for your reply
Thank you very much!
__________________________________________________________
雅虎邮箱,终生伙伴!
http://mail.yahoo.com.cn/
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]