write a c program for sum of array elements
/* c program for sum of array elements */
/*author:sai date:6-4-2015 */
#include<stdio.h>
int main()
{
int a[10];
int i, sum = 0;
printf("\nEnter 10 elements : ");
for (i = 0; i < 10; i++)
scanf("%d", &a[i]);
for (i = 0; i < 10; i++)
{
sum = sum +a[i];
}
printf("The sum of array elements : %d\n", sum);
}
output:
/* c program for sum of array elements */
/*author:sai date:6-4-2015 */
#include<stdio.h>
int main()
{
int a[10];
int i, sum = 0;
printf("\nEnter 10 elements : ");
for (i = 0; i < 10; i++)
scanf("%d", &a[i]);
for (i = 0; i < 10; i++)
{
sum = sum +a[i];
}
printf("The sum of array elements : %d\n", sum);
}
output:
No comments:
Post a Comment