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