WAP that inputs two arrays and saves sum of corresponding elements of these arrays in a third array

 
#include <stdio.h>

int main()
{
    int a[50], b[50], sum[50], i, n;
    printf("Enter the Elements in an array: ");
    scanf("%d", &n);
    printf("Enter the Elements of 1st array: ");
    for (i=0; i<n; i++)
    scanf("%d", &a[i]);
    printf("Enter the Elements of 2nd array: ");
    for (i=0; i<n; i++)
    scanf("%d", &b[i]);
    for (i=0; i<n; i++)
    sum[i] = a[i] + b[i];
    
    printf("Sum of the corresponding element of 1st and 2nd array is ", sum[i]);
    for (i=0; i<n; i++)
    printf("%d,", sum[i]);
    return 0;
}

Comments

Popular posts from this blog

WAP to add or to multiply two matrices of order nXn.

WAP that swaps values of two variables without third variable.