ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2254)
 C++ interview questions  C++ Interview Questions (1111)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (646)
Question
write a program to find the sum of the array elements in c
language?
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
#include<stdio.h>
#include<conio.h>

void main()
{
int a[5];
int 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);
} // end of main()
 
Is This Answer Correct ?    209 Yes 49 No
Anuja Kulkarni
 
Answer
# 2
the above prog is perfect.. 
Is This Answer Correct ?    84 Yes 33 No
Shruti
 
 
 
Answer
# 3
#include<stdio.h>
#include<conio.h>
void main()
{
int n[5],sum=0,i=0;
clrscr();
for(i=0;i<4;i++)
{
scanf("%d",&n[i]);
}

for(i=0;i<4;i++)
{
sum=sum+n[i];
}
printf("sum are%d",sum);
getch();
}
 
Is This Answer Correct ?    46 Yes 24 No
Vaibhav
 
Answer
# 4
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,sum=0;
clrscr();
for(i=0;i<10;i++)
{
printf("\n enter an elements in array");
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
sum=sum+a[i];
}
printf("\n sum is %d",sum);
}
 
Is This Answer Correct ?    29 Yes 13 No
Karnik Ankit
 
Answer
# 5
//c program of sum array element
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,sum=0,n,a[100];
clrscr();
printf("How many number are you entering(less than 100) ?");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
//sum of array element
for(i=1;i<=n;i++)
{
sum=sum+a[i];
}
printf("Sum of your entered number is=%d",sum);
getch();
}//End of main
 
Is This Answer Correct ?    14 Yes 4 No
Rajkumar
 
Answer
# 6
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,sum=0;
clrscr();
for(i=0;i<10;i++)
{
printf("\n enter an elements in array");
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
sum=sum+a[i];
}
printf("\n sum is %d",sum);
}
 
Is This Answer Correct ?    19 Yes 10 No
Vijay
 
Answer
# 7
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];
int i,b=0;
printf("Enter the array elements\n");
for (i=0; i<5; i++)
scanf("%d",&a[i]);
for (i=0; i<5; i++)
{
b=b+a[i];
}
printf("Sum of array elements is %d",b);
}
 
Is This Answer Correct ?    14 Yes 9 No
Syed Shoaib
 
Answer
# 8
/* programm of sum of array value*/
#include<stdio.h>
#include<conio.h>
void main()
{
int array[10],i,sum=0;
for(i=0;i<10;i++)
{
scanf("%d",&array[i];
printf("entered digits are=%d",array[i];
}
sum=sum+array[i]'
for(i=0;i<10;i++)
{
printf("the sum of digits=%d",sum);
}

getch();
}
/*join me on orkut search by name. i will solve your
problem*/
 
Is This Answer Correct ?    13 Yes 8 No
Sumit Aseri
 
Answer
# 9
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],sum=0,n,i;
printf("Enter range");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("The sum of all the elements in the given array
is\n");
for(i=0;i<n;i++)
sum=sum+a[i];
printf("%d",sum);
getch();
}
 
Is This Answer Correct ?    14 Yes 10 No
M.sushma
 
Answer
# 10
#include<Stdio.h>
void main()
{
int sum=0,a[10],i,n;
printf("enter value of n");
scanf("%d",&n);
printf("enter array elements");
for(i=o;i<=n;;i++)
scanf("%d",&a[i]);
for(i=0;i<=n;i++)
{
sum= sum+a[i];
}
printf("sum of all array elements = %d",sum);
}
 
Is This Answer Correct ?    2 Yes 1 No
Aisha
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
who developed c and why he developed c?   5
program to print upper & lower triangle of a matrix TCS 2
44.what is the difference between strcpy() and memcpy() function? 45.what is output of the following statetment? 46.Printf(%x, -1<<4); ? 47.will the program compile? int i; scanf(%d,i); printf(%d,i); 48.write a string copy function routine? 49.swap two integer variables without using a third temporary variable? 50.how do you redirect stdout value from a program to a file? 51.write a program that finds the factorial of a number using recursion?   3
Rapunzel walks into the forest of forgetfullness. She meets a Lion who lies on Monday Tuesdays and Wednesdays and meets a rabbit who lies on Thurs fridays and saturdays . On that day both say that "I lied yesterday". What day is it . TCS 3
where does malloc() function get the memory?   1
How to write a program for swapping two strings without using 3rd variable and without using string functions. iGate 7
second highest number in a given set of numbers TCS 3
What is Dynamic Initialization.   3
What's a "sequence point"?   3
What is the output of the program given below #include<stdio.h> main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); } ADITI 21
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} what would be the output? Wipro 1
Please list all the unary and binary operators in C.   3
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com