I'm a beginner. Well I was just trying out my hand at data structures and could not understand why I was getting the error. I think it would be better to post the code and the output I'm getting. (I use the C-Free 4.0 Compiler), by the way. So here's the code
// Write a C program to enter and display elements of an array
#include <stdio.h>
int main(int argc, char *argv[])
{
int a[44],n,i=0;
// No. of elements:
printf("\n How many elements in all?");
scanf("%d",&n);
// Entering all elements:
printf("\n\n Plz do enter the elements:");
for(;i<n;i++)
scanf("%d",&a[i]);
// Displaying all elements:
printf("\n Array elements are:");
for(i=0;i<n;)
{
printf("\n a[%d]=%d",i,a[i]);
i++;
break;
}
int sum=0;
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf("\nSum=%d",sum);
return 0;
}
/*
And here's the output when I say that I'm entering 3 elements into the array:
How many elements in all?3
Plz do enter the elements:12
0
-22
Array elements are:
a[0]=12
Sum=-10Press any key to continue . . . */
Well as you all can see, I am able to enter values for(i=0;i