write a program to find the sum of the array elements in c
language?

Answer Posted / bishmeet singh

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,sum=0;
printf("enter the no. of elements");
back:
scanf("%d",&n);
if(n<10)
{
printf("elements sholud be less than 10\n enter again");
goto back;
}
printf("Enter %d elements",n);
for(i=0;i<n;i++)
{
scanf("%d",a[i]);
sum=sum+a[i];
}

printf("sum of your entered elements is %d",sum);
getch();
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is use of pointer?

587


What is wrong with this statement? Myname = 'robin';

821


I came across some code that puts a (void) cast before each call to printf. Why?

678


What are the types of assignment statements?

630


What are the advantages of using macro in c language?

592






What is typedf?

670


Why void is used in c?

566


What is a void pointer in c?

608


How can I split up a string into whitespace-separated fields?

571


What is difference between %d and %i in c?

691


Why does the call char scanf work?

620


How will you delete a node in DLL?

686


Why is c used in embedded systems?

614


Can you please explain the scope of static variables?

601


What is unsigned int in c?

560