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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between array and pointer?

569


why do some people write if(0 == x) instead of if(x == 0)?

654


What is static function in c?

635


How can you invoke another program from within a C program?

618


How can I swap two values without using a temporary?

618






How do I read the arrow keys? What about function keys?

616


What does 1f stand for?

614


What does %c do in c?

584


What is the argument of a function in c?

575


Why & is used in c?

715


How can you read a directory in a C program?

651


Why is void main used?

621


Tell us two differences between new () and malloc ()?

614


What are keywords in c with examples?

604


Is boolean a datatype in c?

547