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

Answer Posted / asish manoj k

#include <conio.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int n,r=0,i,a[10],s=0;

printf("enter the size of the array");
scanf("%d",&n);

for(i=0;i<n;i++)
{
printf("enter the %d element",r);
scanf("%d",&a[i]);
r=r+1;

}
for(i=0;i<n;i++)
{

s=s+a[i];
}

printf("sum of the elements of the array is %d",s);
system("PAUSE");
return EXIT_SUCCESS;
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of assignment statements?

630


What is #pragma statements?

591


How many keywords (reserve words) are in c?

621


What is FIFO?

676


Explain the difference between call by value and call by reference in c language?

647






Which header file should you include if you are to develop a function which can accept variable number of arguments?

810


What does %2f mean in c?

674


What is calloc() function?

625


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

1674


What is the explanation for modular programming?

686


How is a structure member accessed?

585


What is a pragma?

670


What is the use of bit field?

642


How can you read a directory in a C program?

651


How pointers are declared?

560