#include<stdio.h>
main()
{
int a[100],n,sum=0,i;
printf("\nEnter number of elements=");
scanf("%d",&n);
printf("\nEnter the elements=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nThe array is=");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
for(i=0;i<n;i++)
sum=sum+a[i];
printf("\nThe sum is=%d\n",sum);
}
main()
{
int a[100],n,sum=0,i;
printf("\nEnter number of elements=");
scanf("%d",&n);
printf("\nEnter the elements=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nThe array is=");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
for(i=0;i<n;i++)
sum=sum+a[i];
printf("\nThe sum is=%d\n",sum);
}
No comments:
Post a Comment