Define two arrays x and f each of size 10 (Please include screenshot of the code
ID: 653171 • Letter: D
Question
Define two arrays x and f each of size 10 (Please include screenshot of the code running)
Define two arrays x and f, each of size 10, using call-by-reference (that is, use pointers), to pass the array to a function, named sum. In main: Define arrays as x={1,2,3,4,5,6,7,8,9,10} and y={ 10,9,8,7,6,5,4,3,2,1}; Pass arrays to a function named as sum array; print out two arrays and the sum on screen. In function sumarray part: Take arrays from main and do the summation according to the formula below: sum=[x0+ (y1/x1)+ (y1*x1)+y9], xi and yi mean element of array you must use call-by-reference (the pointer) to call functions, as required: otherwise, no credits givenExplanation / Answer
#include<stdio.h>
#include<conio.h>
void sum_array(int *x, int *f)
{
int i,sum=0;
for(i=0;i<10;i++)
{
sum=x[i]+f[i];
printf(" %d",sum);
}
getch();
}
void main()
{
int a[]={1,2,3,4,5,6,7,8,9,10};
int b[]={10,9,8,7,6,5,4,3,2,1};
clrscr();
sum_array(a,b);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.