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 |
what is the use of a array in c
who is the founder of c
19 Answers College School Exams Tests, HP,
Why doesnt that code work?
int a=0,b=2; if (a=0) b=0; else b=*10; What is the value of b ?
write a function to swap an array a[5] elements like a[0] as a[5],a[1] as a[4],....a[5] as a[0].without using more than one loop and use one array not to use temp array?
Explain a file operation in C with an example.
What do you mean by invalid pointer arithmetic?
Using which language Test cases are added in .ptu file of RTRT unit testing???
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
0 Answers Aegis, CDAC, Infosys,
what is the difference between while and do while?
if function is declared as static in one source file, if I would like to use the same function in some other source file...is it possible....how ?
Can you please explain the scope of static variables?