write a program to find the sum of the array elements in c
language?
Answers were Sorted based on User's Feedback
Answer / atul lakhera
#include<stdio.h>
#include<conio.h>
void main()
{
int num[10], sum=0;
for(int i=0; i<10; i++)
{
printf("Enter number=");
scanf("%d", &num[i]);
}
printf("Sum of elemets=");
for(i=0; i<10; i++)
{
sum=sum+num[i];
printf("%d", sum);
}
getch();
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / raushan kumar
# include <stdio.h>
# include <conio.h>
void main()
{
int arr[value],sum=0;
int i;
clrscr();
printf("Enter data in array");
/*store data in array*/
for(i=1;i<value;i++)
{
scanf("%d",&arr[i]);
}
/*Print data in array*/
for(j=1;j<value;j++)
{
printf("%d",arr[i]);
sum=sum+arr[i];
}
/*Sum of array element*/
printf("\nArray Element Sum=%d",sum);
getch();
}
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / uday
#include<stdio.h>
void main()
{
int a[i],sum=0;
printf("enter n value");
scanf("%d",&n);
for(i=0;i<n,i++)
{
scanf("%d",&a[i])
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf("sum=%d");
}
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / 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 |
Answer / mohd hayyan
#include<stdio.h>
#include<conio.h>
void main()
{
int a[i],i,sum=0;
clrscr();
printf("enter the array");
for(i=0;i<3;i++)
scanf("%d",&a[i]);
for(i=0;i<3;i++)
{
sum=sum+a[i];
}
for(i=0;i<3;i++)
{
printf("a[%d]=%d",i,a[i]);
}
printf("%d",sum);
getch();
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / bishmeet singh
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,sum=0;
clrscr();
printf("enter the 5 elements to sum");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<5;i++)
{
sum=sum+a[i];
}
printf("sum of the elements is %d",sum);
}
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sayeed khan
#include<stdio.h>
#include<conio.h>
int main()
{
int i,sum=0,a[30],n;
printf("Enter The Number=");
for(i=0;i<n;i++);
scanf("%d",&n);
sum=sum+a[i];
printf("the sum is %d\n",sum);
getch();
return 0;
}
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / lalit suthar, nilod
// write a program to find the sum of the array elements in
c language?
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,sum=0;
clrscr();
printf("Enter the array elements\n");
for (i=0; i<5; i++)
scanf("%d",&a[i]);
// sum of array elements
for (i=0; i<5; i++)
{
sum=sum+a[i];
}
printf("Sum of array elements===%d",sum);
getch();
}
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / mathews m
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,sum=0,x[20];
clrscr();
printf("enter the array space");
scanf("%d",&n);
printf("enter the elements");
for(i=0;i<n;i++)
scanf("%d"&x[i]);
for(i=0;i<n;i++)
{
sum=sum+x[i];
}
printf("the sum of elements in an array=%d");
}
getch();
Is This Answer Correct ? | 1 Yes | 1 No |
Explain c preprocessor?
write a program to delete an item from a particular location of an linear array?
how the compiler treats any volatile variable?Explain with example.
What is the purpose of type declarations?
Why calloc is better than malloc?
i have a written test for microland please give me test pattern
write a program for the normal snake games find in most of the mobiles.
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
program for comparing 2 strings without strcmp()
Why is malloc used?
name the language for writing c compiler?
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..