Here is a program to find the sum of n numbers entered .. I have done this programme in c++ but now I was asked to do it using c.. there is some error with the program.The basic array input ,display thing itself is not working.. Kindly help me .. I hope the while loop part is correct
int main()
{
int i,a[10],sum=0,n;
printf("Enter the number of numbers " );
scanf("%d",&n);
printf("Enter the numbers\n");
for(i=0;i<n;i++)
{
scanf("%d",a[i]);
}
for(i=0;i<n;i++)
printf("%d",a[i]);
while(n>0)
{sum=sum+a[i];
i++;
}
printf("sum = \t%d ",sum);
return 0;
getch();
}