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 difference between functions getch() and getche()?

625


What is the explanation for cyclic nature of data types in c?

652


Explain how do you use a pointer to a function?

642


What is the best style for code layout in c?

634


Why does everyone say not to use scanf? What should I use instead?

685






Which of these functions is safer to use : fgets(), gets()? Why?

637


What are the header files used in c language?

594


How can I avoid the abort, retry, fail messages?

665


Explain enumerated types in c language?

608


What is difference between union All statement and Union?

632


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

650


Difference between Shallow copy and Deep copy?

1576


What is the meaning of c in c language?

601


Why is python slower than c?

611


What is the difference between the = symbol and == symbol?

631