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
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
What is class and object in c?
Is register a keyword in c?
Describe the order of precedence with regards to operators in C.
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
What is realloc in c?
Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc
What is the sizeof () operator?
Hi can anyone tell what is a start up code?
What are the types of macro formats?
What is the use of in c?
What is sizeof array in c?
Where does the name "C" come from, anyway?
Difference between MAC vs. IP Addressing