luc060.c (1098B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 08 Feb 2026 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* For the following set of sample data, compute the standard deviation and the mean.\nData: -6, -12, 8, 13, 11, 6, 7, 2, -6, -9, -10, 11, 10, 9, 2 9 */ 10 11 /* Let Us C, Chap- 13 (Arrays), Qn No.: B(f) */ 12 13 /* This file is auto-generated by a bot. */ 14 /* This code is not compiled; it is for reference only. */ 15 16 17 #include <stdio.h> 18 #include <math.h> 19 #include <stdlib.h> 20 21 int main() 22 { 23 int data[] = {-6, -12, 8, 13, 11, 6, 7, 2, -6, -9, -10, 11, 10, 9, 2}; 24 int n = 15, i; 25 double sum = 0.0, mean, std_dev = 0.0; 26 27 // Calculate Mean 28 for (i = 0; i < n; i++) 29 { 30 sum += data[i]; 31 } 32 mean = sum / n; 33 34 // Calculate Standard Deviation 35 for (i = 0; i < n; i++) 36 { 37 std_dev += pow(data[i] - mean, 2); 38 } 39 std_dev = sqrt(std_dev / n); 40 41 printf("Count: %d\n", n); 42 printf("Mean: %.2f\n", mean); 43 printf("Standard Deviation: %.2f\n", std_dev); 44 45 return 0; 46 }