C Program To Add Two Integer Arrays
C program to add two integer arrays: This program accepts two integer arrays of same size. It adds the corresponding elements of two arrays and stores the result in the third array and print it as well. You can choose to print the result directly without it in another array.
C Program to add two integer arrays
Here is the source code of C program to add two integer arrays/* C program to add corresponding integers of two arrays and save the sum in third array */
#include<stdio.h>
void main()
{
int i,size,arr[100],arr1[100],arr2[100];
printf("\n How many elements to accept for both arrays :- ");
scanf("%d",&size);
printf("\n Enter the elements of first array:-");
for(i=0;i<(size);i++)
scanf("%d",&arr[i]);
printf("\n Enter the elements of second array:-");
for(i=0;i<(size);i++)
scanf("%d",&arr1[i]);
printf("\n arr \t+ arr1 \t= arr2 \n");
for(i=0;i<(size);i++)
printf("\n %d \t+ %d \t= %d \n",arr[i],arr1[i],arr2[i]=arr[i]+arr1[i]);
}
/* Output of above code:-
How many elements to accept for both arrays :- 5
Enter the elements of first array:-1 2 3 4 5
Enter the elements of second array:-10 11 12 13 14
arr + arr1 = arr2
1 + 10 = 11
2 + 11 = 13
3 + 12 = 15
4 + 13 = 17
5 + 14 = 19
*/