Write a program that calculates the standard deviation and the median of a sorte
ID: 3692638 • Letter: W
Question
Write a program that calculates the standard deviation and the median of a sorted array of floating point numbers.(working with Floating Points ).
the programming language is : mips assembly language
please solve this qustion by (programming language >>> mips assembly language ).
Program Structure:
Input: The size of the array
The numbers in the array (assume to be entered sorted)
Output: The standard deviation and the Median.
Definitions: Define variables for the array, array size, standard deviation, and median.
Procedures: Divide the program tasks into procedures, such as: ReadArr, CalcSDev and CalcMedian.
Sample Run(s):
please solve this qustion by (programming language >>> mips assembly language ).
Explanation / Answer
#include <stdio.h>
#include <math.h>
#define MAXSIZE 10
void main()
{
float x[MAXSIZE];
int i, n;
float Median, std_deviation, sum = 0, sum1 = 0;
printf("Enter the value of array ");
scanf("%d", &n);
printf("Enter %d array elements ", n);
for (i = 0; i < n; i++)
{
scanf("%f", &x[i]);
}
/* Compute the sum of all elements */
for (i = 0; i < n; i++)
{
sum = sum + x[i];
}
Median = sum / (float)n;
for (i = 0; i < n; i++)
{
sum1 = sum1 + pow((x[i] - Median), 2);
}
std_deviation = sqrt(variance);
printf("Median of all elements = %.2f ", Median);
printf("Standard deviation = %.2f ", std_deviation);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.