write a program to find the sum of the array elements in c
language?

Answer Posted / heemashree

#include "stdio.h"
#include "conio.h"
#include "stdafx.h"
void main()
{
int a[10];
int i,sum=0,n;

printf("enter number of elements");
scanf("%d",&n);



printf("Enter the array elements\n");
for (i=0; i<n; i++)
scanf("%d",&a[i]);

// sum of array elements
for (i=0; i<n; i++)
{
sum=sum+a[i];
}
printf("Sum of array elements===%d",sum);
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of parallelize in spark?

576


What are the storage classes in C?

625


Write a simple code fragment that will check if a number is positive or negative.

708


why we wont use '&' sing in aceesing the string using scanf

1784


Is fortran faster than c?

581






What is c language & why it is used?

582


find out largest elemant of diagonalmatrix

1651


What is realloc in c?

581


What is difference between %d and %i in c?

692


simple program of graphics and their output display

1469


What are the uses of a pointer?

683


What is #define in c?

622


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

7410


What is sizeof return in c?

617


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

1674