Add array element

C program to add array element :

code

#include<stdio.h>
#include<conio.h>
void main()
{
int  arr[10],i,size,sum=0;
clrscr();
printf(“Enter size of an array :”);
scanf(“%d”,&size);
for(i=0;i<size;i++)
{
printf(“\nEnter element at %d location :”,i);
scanf(“%d”,&arr[i]);
sum=sum+arr[i];
}
printf(“\nAddition of array element :%d”,sum);
getch();
}

 


output

Enter size of an array :5

Enter element at 0 location :10

Enter element at 1 location :30

Enter element at 2 location :20

Enter element at 3 location :30

Enter element at 4 location :10

Addition of array element :100

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s