#include<stdio.h>
int main()
{
int array[100],array1[100],subtract[100];
int i,n,m,index;
printf("Please Enter The 1st array size: ");
scanf("%d",&n);
printf("
Please Enter %d elements of the array:
",n);
for(i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
printf("
Please Enter The 2nd array size: ");
scanf("%d",&m);
printf("
Please Enter %d elements of the array:
",m);
for(i=0; i<m; i++)
{
scanf("%d",&array1[i]);
}
///subtraction
for(i=0; i<n; i++)
{
subtract[i]=array[i]-array1[i];
}
if(n!=m) /// total element of two array need to be same.
{
printf("Not possible to Add
");
}
else
{
printf("
The sum of two array is: ");
for(i=0; i<n; i++)
{
printf("%d ",subtract[i]);
}
}
printf("
");
return 0;
}
Output
Please Enter The 1st array size: 3
Please Enter 3 elements of the array:1 2 3
Please Enter The 2nd array size: 3
Please Enter 3 elements of the array:3 2 1
The sum of two array is:2 0 -2
Add your comment