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
Why is c still so popular?
What is the difference between #include
How can I make sure that my program is the only one accessing a file?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
What are the restrictions of a modulus operator?
What library is sizeof in c?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
What does c mean?
#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); }
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?
Explain the meaning of keyword 'extern' in a function declaration.
What is meant by high-order and low-order bytes?
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.
Which control loop is recommended if you have to execute set of statements for fixed number of times?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?