# 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 custom. You dont entertain to beget chance apportion to discover it easier.

Beget span chance apportions (X_0 and x_1) betwixt 0.0 and 100.0 and apportion their dissent that is regularly express. Repeat this control N spans and discover the medium and the emblem irregularity of the dissents. You’d emend explanation the capacity rx_range(). Your program obtain pertruth your input N from keyboard and explanation a while-loop proposition control the dwelling-upon. If you pick-out a chance apportion betwixt 0 and 100 uninterruptedly, the expected apportion is 50. But, if you pick-out span chance apportions in the rove where each expected prizes are 50, obtain the expected dissent of apportions obtain be 0 (zero)?

Note : Could you delight stop the output .If you required any changes Just nice.I obtain change it.Thank You.

_______________

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

embrace medium(embrace accoutre[], int N);
embrace rxRange();
embrace stanDev(embrace accoutre[], int N, embrace medium);
int deep()
{
// Declaring variables
int i = 0, N;
embrace rand1, rand2;

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

/* Intializes chance apportion generator */
seedVal = (unsigned)time(&t);
srand(seedVal);

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

// Creating an doublle emblem accoutre
embrace diffs[N];

// Generating the dissents of span chance apportions
while (i < N)
{
while (1)
{
// Getting the span chance apportions
rand1 = rxRange();
rand2 = rxRange();

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

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

// Calling the capacitys
embrace avg = medium(diffs, N);
embrace sd = stanDev(diffs, N, avg);

// Displaying the output
printf(“Medium : %.2fn”, avg);
printf(“Emblem Irregularity : %.2f “, sd);

return 0;
}

/* beget a chance shapeless subject-matter apportion from min to max */
embrace rxRange()
{
embrace rove = (100.0 – 0.0);
embrace div = RAND_MAX / rove;
return (rand() / div);
}

// This capacity obtain apportion the emblem irregularity
embrace stanDev(embrace accoutre[], int N, embrace medium)
{
embrace irregularity;
embrace blend = 0.0;
int i;
// Calcualting the disunite of emblem devoation
control (i = 0; i < N; i++)
{
blend += pow((array[i] – medium), 2);
}

// Calcualting emblem devoation
irregularity = sqrt((sum) / (N));

return irregularity;
}
// This capacity obtain calcualte the medium
embrace medium(embrace accoutre[], int N)
{
int i;
embrace blend = 0.0;
control (i = 0; i < N; i++)
{
blend += accoutre[i];
}
return (double)blend / N;
}

_________________

Output: