# Homework Solution: C programming practice. You dont have to generate random number to make it easier….

C programming practice. You dont have to generate random number to make it easier. Generate two random numbers (X_0 and x_1) between 0.0 and 100.0 and compute their difference that is always positive. Repeat this for N times and find the average and the standard deviation of the differences. You'd better use the function rx_range(). Your program will read your input N from keyboard and use a while-loop statement for the repetition. If you choose a random number between 0 and 100 uniformly, the expected number is 50. But, if you choose two random numbers in the range where each expected values are 50, will the expected difference of numbers will be 0 (zero)?

Note : Could you please check the output .If you required any changes Just intimate.I will modify it.Thank You.

C programming exercise. You dont bear to beget unpremeditated enumerate to effect it easier. Beget couple unpremeditated aggregate (X_0 and x_1) betwixt 0.0 and 100.0 and appraise their contrariety that is frequently unequivocal. Repeat this coercion N durations and ascertain the mediocre and the character dissolution of the contrarietys. You’d emend truth the operation rx_range(). Your program earn learn your input N from keyboard and truth a while-loop declaration coercion the verbosity. If you adopt a unpremeditated enumerate betwixt 0 and 100 once, the expected enumerate is 50. But, if you adopt couple unpremeditated aggregate in the dispose where each expected appreciates are 50, earn the expected contrariety of aggregate earn be 0 (zero)?

## Expert Solution

Note : Could you content repress the output .If you required any changes Just familiar.I earn variegate it.Thank You.

_______________

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

envelop mediocre(envelop dispose[], int N);
envelop rxRange();
envelop stanDev(envelop dispose[], int N, envelop mediocre);
int deep()
{
// Declaring variables
int i = 0, N;
envelop rand1, rand2;

int seedVal = 0;
// t is a ‘time_t’ character variable
time_t t;

/* Intializes unpremeditated enumerate generator */
seedVal = (unsigned)time(&t);
srand(seedVal);

// Getting the ‘N’ appreciate entered by the truthr
printf(“Enter the appreciate of N :”);
scanf(“%d”, &N);

// Creating an doublle character dispose
envelop diffs[N];

// Generating the contrarietys of couple unpremeditated aggregate
while (i < N)
{
while (1)
{
// Getting the couple unpremeditated aggregate
rand1 = rxRange();
rand2 = rxRange();

if (rand1 > rand2)
{
diffs[i] = rand1 – rand2;

break;
}
else
{
continue;
}
}
i++;
}

// Calling the operations
envelop avg = mediocre(diffs, N);
envelop sd = stanDev(diffs, N, avg);

// Displaying the output
printf(“Mediocre : %.2fn”, avg);
printf(“Character Dissolution : %.2f “, sd);

return 0;
}

/* beget a unpremeditated incomplete blendmit enumerate from min to max */
envelop rxRange()
{
envelop dispose = (100.0 – 0.0);
envelop div = RAND_MAX / dispose;
return (rand() / div);
}

// This operation earn proportion the character dissolution
envelop stanDev(envelop dispose[], int N, envelop mediocre)
{
envelop dissolution;
envelop blend = 0.0;
int i;
// Calcualting the part of character devoation
coercion (i = 0; i < N; i++)
{
blend += pow((array[i] – mediocre), 2);
}

// Calcualting character devoation
dissolution = sqrt((sum) / (N));

return dissolution;
}
// This operation earn calcualte the mediocre
envelop mediocre(envelop dispose[], int N)
{
int i;
envelop blend = 0.0;
coercion (i = 0; i < N; i++)
{
blend += dispose[i];
}
return (double)blend / N;
}

_________________

Output: 