Sum of two array and store them in third array

Program:

#include<stdio.h>
int main()
{
int a[10],b[10],c[10],n,i;
printf("Enter size of array: ");
scanf("%d",&n);
printf("Enter %d elements of array A:\n",n);
for(i=0;i<n;i++)
{
  scanf("%d",&a[i]);
}
printf("Enter %d elements of array B:\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("Third array: \n");
for(i=0;i<n;i++)
{
  printf("%d\t",c[i]);
}
return 0;

}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...