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

Answer Posted / m.sushma

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],sum=0,n,i;
printf("Enter range");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("The sum of all the elements in the given array
is\n");
for(i=0;i<n;i++)
sum=sum+a[i];
printf("%d",sum);
getch();
}

Is This Answer Correct ?    19 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why structure is used in c?

574


How is a macro different from a function?

648


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

2296


How is pointer initialized in c?

577


What is getch c?

844






Why static variable is used in c?

546


What are the differences between new and malloc in C?

602


What is the use of header?

612


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

1716


What is the purpose of the statement: strcat (S2, S1)?

636


What is the collection of communication lines and routers called?

604


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1646


When is a “switch” statement preferable over an “if” statement?

639


Explain what are the standard predefined macros?

642


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

643