### Array : Adding Two Arrays

```/* Problem: Add the corresponding values from two arrays
of the same size. */
#include <stdio.h>

/* the function that adds the two arrays a1 and a2. it "returns" a3 back */
void
addarrays (int a1[], int a2[], int a3[], int n)
{
int i;

/* do the adding of every corresponding cells */
for (i=0; i<n; ++i)
a3[i] = a1[i] + a2[i];
}

int
main (void)
{
int x[] = {1,2,3,4}, i;
int y[] = {10,20,30,40};
int z[4];

/* call the function */

/* print a report */
for (i=0; i<4; ++i)
printf ("%3d", x[i]);

printf ("\n + \n");

for (i=0; i<4; ++i)
printf ("%3d", y[i]);

printf ("\n-------------\n");

for (i=0; i<4; ++i)
printf ("%3d", z[i]);

return (0);
}```

1. Get the easy way of approaching any array program in c at PROGRAMMING HUB. You will like it

2. //Add the corresponding values from two arrays of the same size.
include(stdio.h)
void add (int a1[],int a2[],int a3[],int n)
{
int i=0;
while(i<n)
{
a3[i]=a1[i]+a2[i];
i++;
}
}
int main(void)
{
int x[4]={99,6,55,36},i=0;
int y[4]={12,1,44,30};
int z[4];
while(i<4)
{
printf("%4d",x[i]);
i++;
}
printf("\n+\n");
i=0;
while(i<4)
{
printf("%4d",y[i]);
i++;
}
printf("\n-----------------\n");
i=0;
while(i<4)
{
printf("%4d",z[i]);
i++;
}
getch();
}

3. #include
main()
{
int a[4]={2,3,4,5};
int sum=0,i;
int b[4]={3,4,5,6};
for(i=0;i<4;i++)

{
sum=a[i]+b[i];

printf("%d\n",sum );
}
}

4. #include
using namespace std;
int main()
{
int array[4]={2,3,4,5},array2[4]={4,6,2,8},i,sum=0;
for(i=0;i<4;i++)
{
sum=array[i]+array2[i];
cout<<sum<<endl;
}
}

5. #include
int main(){
int p[3]={1,2,3};
int q[3]={3,2,1};
int i,sum=0;
for(i=0;i<=3;i++)
{
sum+=p[i]+q[i];

printf("%d\n",sum);
}
}

6. #include
int main()
{
int sum=0,i,a[5]={1,2,3,4,5},b[3]={6,7,8};
for(i=0;i<3;i++)
{
sum=a[i]+b[i];
printf("\n%d",sum);
}
}

7. Name : Sumsunnahar Nawa
ID : 201710090
Batch:54th

8. Shipon Hossan
ID-201810009

9. Dilruba Parvin Tonni
ID-201810641

10. Fazlul Haque Rana
ID-201810233

11. ID: 201810037

12. Shamima Islam Sima
ID-201810532