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

Why is c still so popular?

620


What is the difference between #include

and #include “header file”?

557


How can I make sure that my program is the only one accessing a file?

686


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

677


What are the restrictions of a modulus operator?

641






What library is sizeof in c?

576


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

664


What does c mean?

594


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

633


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

986


Explain the meaning of keyword 'extern' in a function declaration.

733


What is meant by high-order and low-order bytes?

658


Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

657


Which control loop is recommended if you have to execute set of statements for fixed number of times?

816


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

774