C Program to find the addition of the elements of two one-dimensional Array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],b[50],c[50],i,n;
printf("Enter the size of array
:\t");
scanf("%d",&n);
printf("\nEnter %d elements in
first array :\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nEnter the %d elements
in second array :\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<n;i++)
{
c[i]=a[i]+b[i];
}
printf("\nSum of these two array
is :\n");
for(i=0;i<n;i++)
{
printf("%d ",c[i]);
}
getch();
}
Output :-
Enter the size of array : 4
Enter 4 elements in first array :
1 2 3 4
Enter the 4 elements in second array :
4 3 2 1
Sum of these two array is :
5 5 5 5
0 Comments
Tell us your queries or more topics which you want