#include<stdafx.h>
int main()
{
int isbn[10];
int isbnSum;
int i;
for (i=1;i<=10;i++)
{
printf("Enter digit # %d of isbn number.\n", i);
scanf("%d", &isbn);
}
for (i=1;i<=10;i++)
{
isbnSum += isbn;
}
printf("Sum: %d\n", isbnSum);
return 0;
}
Each time i run this program I get some really weird number, almost like an integral memory address location. I want it to add all of the values that belong to the array from array position 1 to 10. I can't spot an error in my code, but it is clear that there must be if i'm not getting the value I should get.
What am I doing wrong?
int main()
{
int isbn[10];
int isbnSum;
int i;
for (i=1;i<=10;i++)
{
printf("Enter digit # %d of isbn number.\n", i);
scanf("%d", &isbn);
}
for (i=1;i<=10;i++)
{
isbnSum += isbn;
}
printf("Sum: %d\n", isbnSum);
return 0;
}
Each time i run this program I get some really weird number, almost like an integral memory address location. I want it to add all of the values that belong to the array from array position 1 to 10. I can't spot an error in my code, but it is clear that there must be if i'm not getting the value I should get.
What am I doing wrong?