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
  • 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....

  • ***Please complete the code in C*** Write a program testArray.c to initialize an array by getting...

    ***Please complete the code in C*** Write a program testArray.c to initialize an array by getting user's input. Then it prints out the minimum, maximum and average of this array. The framework of testArrav.c has been given like below Sample output: Enter 6 numbers: 11 12 4 90 1-1 Min:-1 Max:90 Average:19.50 #include<stdio.h> // Write the declaration of function processArray int main) I int arrI6]i int min-0,max-0 double avg=0; * Write the statements to get user's input and initialize the...

  • 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...

  • 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...

  • 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 -...

  • 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();...

  • please use the c language Assignment 12 The program to write in this assignment is a...

    please use the c language Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...

  • Write a C program that calculates exact change. In order to receive full credit, please remember...

    Write a C program that calculates exact change. In order to receive full credit, please remember that only int arithmetic is exact, so you’ll need to break up your double into two ints, the one before the decimal point and the one after the decimal point. Another point worth mentioning is that the % operator gives the remainder. In other words, when working with int values, 9 / 5 = 1 whereas 9 % 5 = 4. Keep this in...

  • # 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....

  • 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
ADVERTISEMENT