C code:
#include <stdio.h>
#include <math.h>
int main()
{
int n,i;
scanf("%d", &n); //read input n
float data[n]; //array of size n, to store data
for( i=0; i < n; i++) //to read n number of inputs
{
scanf("%f", &data[i]);
}
//minimum value
float minValue = data[0]; //initial assumption
for( i=1; i<n; i++)
{
if (minValue > data[i])
{
minValue = data[i]; // update with minimum value
}
}
printf("The Minimum value m = %.6f \n", minValue );
//maximum value
float maxValue = data[0]; //initial assumption
for( i=1; i<n; i++)
{
if (maxValue < data[i])
{
maxValue = data[i]; // update with maximum value
}
}
printf("The Maximum value M = %.6f \n", maxValue );
//average
float sum = 0.0, avg;
for(i=0; i<n; i++)
{
sum += data[i]; //sum of all numbers
}
avg = sum/n; //average
printf("The Average value a = %.6f \n", avg );
//Standard Deviation
float sumSquares = 0.0, standardDeviation;
for(i=0; i<n; i++)
{
sumSquares += pow(data[i] - avg, 2); //sum of squares of difference of numbers from average
}
standardDeviation = sqrt(sumSquares/n);
printf("The Standard Deviation s = %.6f \n", standardDeviation);
return 0;
}
Code Screenshot :
Output :
(Q2) Calculating the Distribution of Values 10 marks For a set of n real numbers {xi,...,...
In Unix/Linux, input and output are treated as files and referenced by the operating system using file descriptors. When you open a shell session, for example, three file descriptors are in use: 0 standard input (stdin) 1 standard output (stdout) 2 standard error (stderr) By default, the command interpreter (shell) reads keyboard input from file descriptor 0 (stdin) and writes output to file descriptor 1 (stdout), which appears on the screen. As you explored in Lab 2, input/output can be...
Write a program in c++ that generates a 100 random numbers between 1 and 1000 and writes them to a data file called "randNum.dat". Then re-open the file, read the 100 numbers, print them to the screen, and find and print the minimum and maximum values. Specifications: If your output or input file fails to open correctly, print an error message that either states: Output file failed to open Input file failed to open depending on whether the output or...
i need help with 2b please is a set of input values, Y- 2. In this question, we reuse the notation of lecture 37: X-{xi, ,x , m-1) is a set of hash values, and H is an [X → Y)-valued random variable {0.1, In lecture, we showed that for any hash value y e Y, the expected number of input values that hash to y is k/m, where k XI and m Yl. However, in determining the time it...
create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines and using try-catch-finally blocks in your methods that read from a file and write to a file, as in the examples in the lesson notes for reading and writing text files. Input File The input file - which you need to create and prompt the user for the name of - should be called 'data.txt', and it should be created according to the instructions...
PROGRAM DESCRIPTION Implement the combined O(n) radix/bucket sort as described in class. (i.e. divide the input by radix, bucket sort (with no insertion sort step) once for each radix starting from the least significant. Make sure that your overall implementation is O(n) NPUT The input to your program will an unspecified number of entries. Each entry is a non-negative integer containing nine (zero padded) digits ( this means that the integer may have either leading or trailing zeros), one per...
2. (a) (10 marks) Suppose A is an n x n real matrix. Show that A can be written as a sum of two invertible matrices. HINT: for any XER, we can write A= XI + (A - XI) (b) (10 marks) Suppose V is a proper subspace of Mn.n(R). That is to say, V is a subspace, and V #Mnn(R) (there is some Me M.,n(R) such that M&V). Show that there exists an invertible matrix M e Mn.n(R) such...
2 Happy Numbers 2.1 Definition The definition of a happy number, from wikipedia Given a number n = no, define a sequence n1, n2, … where ni+1 1S the sum of the squares of the digits of n,. Then n is happy if and only if there exists i such that ni 1 It can be shown (see wikipedia) that n is unhappy if the number 4 appears in the sequence. 2.2 The program Write a C++ program happy.cpp which...
Basic C program Problem: In this assignment, you have to read a text file (in.txt) that contains a set of point coordinates (x,y). The first line of the file contains the number of points (N) and then each line of the file contains x and y values that are separated by space. The value of x and y are an integer. They can be both negative and positive numbers. You have to sort those points in x-axis major order and...
Q1. Let x(n) be a complex values sequence with real part xr(n) and the imaginary part xi(n). Prove the following z-transform two relations: XR(2) 4 Z [ZR(n)] = _X(z) + X* (z*) 2 and X (2) - X* (*) X1() = Z XI(n) = - 2 Must you use only MATLAB in your proof, and for x(n), use two random sequences for real and the imaginary parts.
3. Suppose Xi, X2, and X are independent random variables drawn from a binomial distribution with parameters p and n. The observed values are Xi -3, X2-4, and (a) Suppose n 12 and p is unknown. What is the maximum likelihood estimator (b) Suppose p - 0.4 and n is unknown. What is the maximum likelihood estimator for p? for n? (Note: Since n is discrete you can't use calculus for this; just write the formula and use trial and...