Question: Draw a flowchart for this program source code in C: #include #include #define SIZE 9 9 int main ( ) { int data [ SIZE

Draw a flowchart for this program source code in C:
#include
#include
#define SIZE 99
int main(){
int data[SIZE]={
6,7,8,9,8,7,8,9,8,9,
7,8,9,5,9,8,7,8,7,8,
6,7,8,9,3,9,8,7,8,7,
7,8,9,8,9,8,9,7,8,9,
6,7,8,7,8,7,9,8,9,2,
7,8,9,8,9,8,9,7,5,3,
5,6,7,2,5,3,9,4,6,4,
7,8,9,6,8,7,8,9,7,8,
7,4,4,2,5,3,8,7,5,6,
4,5,6,1,6,5,7,8,7
};
printf("This program calculates and displays the mean, median, mode, and the frequency of the mode for a given set of data items.
");
printf("Given the following 99 data points stored in an array:
");
for (int i =0; i < SIZE; i++){
printf("%d", data[i]);
if (i != SIZE -1)
printf(",");
if ((i +1)%10==0)// Print newline every 10 elements
printf("
");
}
printf("
");
double sum =0.0;
// Sort the array for median and mode calculation
for (int i =0; i < SIZE -1; i++){
for (int j =0; j < SIZE - i -1; j++){
if (data[j]> data[j +1]){
int temp = data[j];
data[j]= data[j +1];
data[j +1]= temp;
}
}
}
// Mean calculation
for (int i =0; i < SIZE; i++){
sum += data[i];
}
double mean = sum / SIZE;
// Median calculation
double median;
if (SIZE %2==0){
median =(data[SIZE /2-1]+ data[SIZE /2])/2.0;
} else {
median = data[SIZE /2];
}
// Mode calculation
int mode = data[0], modeFrequency =1, tempFrequency =1;
for (int i =1; i < SIZE; i++){
if (data[i]== data[i -1]){
tempFrequency++;
} else {
if (tempFrequency > modeFrequency){
modeFrequency = tempFrequency;
mode = data[i -1];
}
tempFrequency =1;
}
}
// Check for the last value
if (tempFrequency > modeFrequency){
modeFrequency = tempFrequency;
mode = data[SIZE -1];
}
printf("The mean (average) is: %.2f
", mean);
printf("The median (middle value) is: %.2f
", median);
printf("The mode (most frequent value) is: %d
", mode);
printf("The frequency of the mode is: %d
", modeFrequency);
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!