PROGRAM NO : 1
DATE : 17.06.2025
QUESTION
Write a C program to find the sum, average, standard deviation for a given set of numbers
AIM
To find the sum, average and standard deviation for a given set of numbers
ALGORITHM
Step 1: Start
Step 2: Declare five float variables: a, b, c, d, e
Step 3: Declare float variables: sum, avg, and std for sum, average, and standard deviation
Step 4: Assign values to the variables a, b, c, d, e
Step 5: Calculate the sum
sum = a + b + c + d + e
Step 6: Calculate the average
avg = sum / 5
Step 7: Calculate the standard deviation using the formula
Step 8: Display the values of sum, avg, and std
Step 9: Stop
CODE
#include <stdio.h>
#include <math.h>
int main() {
float a=10;
float b=10;
float c=10;
float d=10;
float e=10;
float sum, avg, std;
// Calculate sum and average
sum = a + b + c + d + e;
avg = sum / 5;
// Calculate standard deviation
std = sqrt(((a - avg)*(a - avg) + (b - avg)*(b - avg) +
(c - avg)*(c - avg) + (d - avg)*(d - avg) +
(e - avg)*(e - avg)) / 5);
printf("Sum = %.2f\n", sum);
printf("Average = %.2f\n", avg);
printf("Standard Deviation = %.2f\n", std);
return 0;
}
RESULT
The program assigns values to five variables.
It then calculates:
● SUM, which is the total of all five numbers added together.
● AVERAGE, which is the sum divided by five, representing the central value.
● STANDARD DEVIATION, which indicates how much the numbers vary or spread out
from the average.
Then it displays the calculated sum, average, and standard deviation.
OUTPUT
Sum = 50.00
Average = 10.00
Standard Deviation = 0.00