/* Sum of two arrays */
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of elements in the arrays: ");
scanf("%d", &n);
int a[n], b[n], i;
for(i = 0; i < n; i++){
printf("Enter element %d of array 1 and array 2: ", i+1);
scanf("%d %d", &a[i], &b[i]);
}
printf("Printing the first array you entered.....\n");
for(i = 0; i < n; i++)
printf("%d ", a[i]);
printf("\nPrinting the second array you entered.....\n");
for(i = 0; i < n; i++)
printf("%d ", b[i]);
printf("\nPrinting the sum of two arrays.....\n");
for(i = 0; i < n; i++)
printf("%d ", a[i]+b[i]);
return 0;
}
Comments
Post a Comment