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

COP 2220 Intro to programming in C (answer in C, NOT in C++), please include com

ID: 3813202 • Letter: C

Question

COP 2220 Intro to programming in C (answer in C, NOT in C++), please include comments.

1. Write the code that executes the following steps:

*Declare an integer array called grades that can store MAX values.

*Write the function call for the function called DisplayGrades that takes the declared array of integers as an argument and the number of elements in the array as the second argument. DisplayGrades does not return anything.

*Write the function definition for the user-definition function DisplayGrades that takes an array of integers and the number of elements in the array as arguments. The function displays the contents of the array.

Explanation / Answer

#include <stdio.h>

/*Definition of DisplayGrades function */
DisplayGrades(int grades[],int MAX){
/*printing the values in the grades array */
int i=0;
for(i=0;i<MAX;i++)
printf("%d ",grades[i]);
}
int main()
{int MAX=10; //you can change this according to your need
int grades[]={1,2,3,4,5,6,7,8,9,10} ;//you can store the values according to your need
DisplayGrades(grades,MAX);//calling the DisplayGrades function
  

return 0;
}

/***********OUTPUT**********
1 2 3 4 5 6 7 8 9 10
**********OUTPUT*************/