Question

Task 6: Arrays: Statistics Calculations Write a C program which accepts a large mumber of real numbers and calculates their

Please Provide Code for above question , be sure that the C code compiles using GCC

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//C program

#include<stdio.h>
int main(){
   float x[9] = {1,2,3,4,5,6,7,8,9};
   float variance , mean;
   float sum1=0, sum2=0;
  
   int n;
  
   for(n=0;n<9;n++)sum1=sum1+x[n];
   mean = sum1/n;
  
   for(n=0;n<9;n++)sum2 =sum2+(x[n]-mean)*(x[n]-mean);
  
   variance = sum2/(n-1);
  
   printf("Mean: %f\nVariance: %f\n",mean,variance);
   return 0;
  
}

//sample output

C\Users\IshuManish\Documents\variance.exe Mean 5.000000 Jariance: 7.500000 Process exited after 0.1391 seconds with return va

Add a comment
Know the answer?
Add Answer to:
Please Provide Code for above question , be sure that the C code compiles using GCC...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following code below must be able to run using linked list instead of using arrays...

    The following code below must be able to run using linked list instead of using arrays ------------------------------------------------------------------------------------------------------- #include #include using namespace std; //Class for standard deviation class stdDev { private:        int max;        double value[100];        double mean; public:        double CalMean()        {               double sum = 0;               for (int i = 0; i < max; i++)                      sum += value[i];               return (sum / max);        }        double CalVariane()        {               mean = CalMean();...

  • C linux please write it by only using “if and else” conditions, thanks so much this...

    C linux please write it by only using “if and else” conditions, thanks so much this is my task 3 Requirements 1. Copy your solution for Task 3 t3.c to a new file t4.c. 2. The input is guaranteed to contain at least one non-whitespace character. 3. If the input is well-formed, i.e., can be parsed to a number, the program should behave identically to Task 3. All the requirements of Task 3 still apply except the file name. 4....

  • I'm not too sure what the question is asking for when calculating for S, we need...

    I'm not too sure what the question is asking for when calculating for S, we need to use MatLab for writing the script. If anybody could be of some assistance, I need the script, and the sample output to match 8. Let n be the number of elements in a data set and let x denote an individual element, for i 1,2,. .. , n. The mean /u and standard deviation s are given by ηΣ α-(ΣΗ ) n(n -...

  • Question 1. Assume the following C program and You are writing code using SPIM to implement...

    Question 1. Assume the following C program and You are writing code using SPIM to implement this program. Write the results of each of the following in MIPS instructions. Use registers $t0 - $t7 as needed, Note: int requires 8 bytes 1. Load the contents of dot_prod and i into registers 2. Load the contents of a[i] and b[i] into registers 3. Calculate dot_prod + a[i]*b[i] and save the result into dot_prod please answer each point from (1,2,3) in separated...

  • # 3. The following code draws a sample of size $n=30$ from a chi-square distribution with...

    # 3. The following code draws a sample of size $n=30$ from a chi-square distribution with 15 degrees of freedom, and then puts $B=200$ bootstrap samples into a matrix M. After that, the 'apply' function is used to calculate the median of each bootstrap sample, giving a bootstrap sample of 200 medians. "{r} set.seed (117888) data=rchisq(30,15) M=matrix(rep(0,30*200), byrow=T, ncol=30) for (i in 1:200 M[i,]=sample(data, 30, replace=T) bootstrapmedians=apply(M,1,median) (3a) Use the 'var' command to calculate the variance of the bootstrapped medians....

  • Please answer this question using python programming only and provide a screen short for this code....

    Please answer this question using python programming only and provide a screen short for this code. Homework 3 - Multiples not less than a number Question 1 (out of 3) This homework is a SOLO assignment. While generally I encourage you to help one another to learn the material, you may only submit code that you have composed and that you understand. Use this template to write a Python 3 program that calculates the nearest multiple of a number that...

  • Please read the question carefully and in full and then answer it (using C language and...

    Please read the question carefully and in full and then answer it (using C language and any necessary libraries). (I am not sure what the expert's mean by when to move to using pipe. I guess if you need to, then you can use a random time or any exact time but make sure to put a comment next to it). you might use the below code to give you some idea: #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<sys/types.h> #include<string.h> #include<sys/wait.h> void main()...

  • Please solve on only PART 2 b) and c) , PART 1 is only for REFERENCE...

    Please solve on only PART 2 b) and c) , PART 1 is only for REFERENCE :) Part I: Ene concept of a percentile (equivalently, quantile) is very important in data analysis. It applies to both samples and distributions. So, let's get some wi practice with them, starting with the binomial distribution. In prelab, you learned that the function gbinom(p. size prob) gives the p-th quantile of the binomial distribution with parameters n - size and pi prob. tocus on...

  • Due Mon 0vn MA 120 Basic Statistics Homework Assignment 2 PLEASE SHOW ALL WORK ON SEPARATE...

    Due Mon 0vn MA 120 Basic Statistics Homework Assignment 2 PLEASE SHOW ALL WORK ON SEPARATE PAPER. Do your own work. Pollow instructions. Point values are in parentheses 1, suppo sex is binomial with n 25, p - 0.38. (5) (a) Calculate P(x12) (10) (b) Calculate P (9 x 11) c) For this binomial distribution, calculate the mean , variance and standard deviation (5) 2. On the SAT test, clyde klutz achieved a score of 387. The national mean for...

  • USING THE C++ CODE BELOW, CAN YOU PLEASE SOLVE THE QUESTION AND EXPLAIN THE STEPS. class...

    USING THE C++ CODE BELOW, CAN YOU PLEASE SOLVE THE QUESTION AND EXPLAIN THE STEPS. class StaticStack { private: int *stack; int capacity; int top; // index of the top element public: StaticStack(int size); // constructor ~StaticStack(); bool isFull(); bool isEmpty(); void push(int); int pop(); }; #include "StaticStack.h" #include <iostream> using namespace std; StaticStack::StaticStack(int size) { stack = new int[size]; // constructing a size sized array capacity = size; top = -1; // empty stack    } StaticStack::~StaticStack() { delete...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT