I’m studying for my C Programming class and need an explanation.

I have to use this code and its output to find the standard deviation of 5 separate inputs

here is the pseudo code

  • varianceSum = 0
  • for(i=0;i<RAINFALL_COUNT;i++)
    • delta = rainfallArray[i] – average
    • varianceSum = varianceSum + delta * delta
  • variance = sum / RAINFALL_COUNT
  • stdDev = sqrt(variance)
  • printf(“Standard Deviation: %lfn”, stdDev)

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <stdlib.h>

#define RAINFALL_COUNT 5

void main()

{

double rainfallArray[RAINFALL_COUNT] = { 0.0 };

int i;

double nextRainfall = 0;

double sum = 0.0;

double average = 0.0;

for (i = 0; i < RAINFALL_COUNT; i++)

{

printf(“Enter the next rainfall amount: “);

scanf(“%lf”, &nextRainfall);

rainfallArray[i] = nextRainfall;

sum += nextRainfall;

}

average = sum / RAINFALL_COUNT;

printf(“Total: %.2lf Average: %.2lfn”, sum, average);

system(“pause”);

}

I have to use this code and its output to find the standard deviation of 5 separate inputs

here is the pseudo code

  • varianceSum = 0
  • for(i=0;i<RAINFALL_COUNT;i++)
    • delta = rainfallArray[i] – average
    • varianceSum = varianceSum + delta * delta
  • variance = sum / RAINFALL_COUNT
  • stdDev = sqrt(variance)
  • printf(“Standard Deviation: %lfn”, stdDev)