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

Lab02 - Data Analysis Problem The purpose of this lab is to introduce more compl

ID: 3743461 • Letter: L

Question

Lab02 - Data Analysis Problem The purpose of this lab is to introduce more complex data manipulation using assembly language. You will be exploring concepts relating to data storage and looping structures while analyzing a random set of grade values. Your program will calculate the minimum and maximum grades along with the average and median grades of the set. Assignment Create a project that will allow you to enter a random set of grades and provide storage for the results in RAM. Use meaningful names for your RAM storage locations to help make your code more readable. You should provide locations for your grade data, minimum grade, maximum grade, average grade, and median grade. Allowed grades are between 0-100. You will indicate the end of the grade set with a value of -1

Explanation / Answer

#include <stdio.h>

int main()
{
int array[100], minimum, size, c,d, maximum,location = 1,location2=1,i;
int loop,sum=0;
float avg;
sum = avg = 0;
printf("Enter required number of elements in the array ");
scanf("%d",&size);

printf("Enter %d the integers ", size);

for ( c = 0 ; c < size ; c++ )
scanf("%d", &array[c]);

minimum = array[0];

for ( c = 1 ; c < size ; c++ )
{
if ( array[c] < minimum )
{
minimum = array[c];
location = c+1;
}
}

printf("Min. element is at location %d and its value is %d. ", location, minimum);

maximum = array[0];

for (d = 1; d < size; d++)
{
if (array[d] > maximum)
{
maximum = array[d];
location2 = d+1;
}
}

printf("Max. element is at location %d and it's value is %d. ", location2, maximum);

for(loop = 0; loop < size; loop++)
sum = sum + array[loop];


avg = (float)sum / loop;
printf("Average of array values is %.2f", avg);

return 0;
}