Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a programmer defined function to add the elements of two arrays of 5 integ

ID: 3818732 • Letter: W

Question

Write a programmer defined function to add the elements of two arrays of 5 integers each. Your main function should declare three integer arrays- two for holding the elements to be added and 1 for holding the sum, and ask the user the enter the value for the first two arrays. Then, you need to call your programmer defined function and pass the three arrays to it. Now your function needs to compute the sum from the elements of the first two array and store in the third array. Display the elements of the sum array that in your main function.

Explanation / Answer

#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[5],b[5],c[5];
clrscr();
printf(" Reading the 1st array ");
for (i=0;i<5;i++)
{
printf("Enter the value");
scanf("%d",&a[i]);
}
printf(" Reading the 2nd array ");
for (i=0;i<5;i++)
{
printf("Enter the value");
scanf("%d",&b[i]);
}
c[5] = sum(a[], b[]);
printf(" The output of addition of 2 array is ");
int sum(a[5],b[5])
{
for(i=0;i<5;i++)
{
c[i]=a[i]+b[i];
return c[i];
printf(" the sum of %d & %d is %d",a[i],b[i],c[i]);
}
}
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote