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:
#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