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

Help me, pls give handwritten answer. tq 3. The C program in Figure 2 below is u

ID: 3891269 • Letter: H

Question

Help me, pls give handwritten answer. tq

3. The C program in Figure 2 below is used to input and output integer arrays. It contains some errors. Identify the errors and explain how the errors can be corrected. # include int inputarray(int a) int outputarray (int a); int main (void int a(2] inputarray (a); outputarray(a); system("pause") return 0; int inputarray (int a) int i printf("Input a [&d;] : ", scanf("%d", a); ) printf ("Array complete!n") return 0; int outputarray(int a) t int i printf ("Array a is:n") for (i 0 i

Explanation / Answer

#include <stdio.h>

// Here is a is an array not a variable. so add the brackets
int inputarray(int a[]);
int outputarray(int a[]);

int main(void)
{
int a[2];
inputarray(a);
outputarray(a);
system("pause");
return 0;
}
// Here is a is an array not a variable. so add the brackets
int inputarray(int a[]){
int i;
// In the for loop the statement should be i = 0 not i ==0
// Previous Statement
//for(i == 0; i < 3; i++){
//Correct one
for(i = 0; i < 3; i++){
printf("Input a[%d]: ", i);
// use & and i to read the ith value for the array
scanf("%d", &a[i]);
}
printf("Array Complete: ");
return 0;
}
// Here is a is an array not a variable. so add the brackets
int outputarray(int a[]){
int i;
printf("Array a is: ");
// In the for loop the statement should be i = 0 not i ==0
// Previous Statement
//for(i == 0; i < 3; i++){
//Correct one
for(i=0; i < 3; i++)
printf("a[%d]: %d ", i , a[i]); // to print the ith element of the array use a[i]
return 0;
}