+ 22
// please input appropriate headers for meh // m lazy int array[5]; int sum = 0; int sum_sqr = 0; int mean; int std_dev; for (int i = 0; i < 5; i++) { std::cin >> array[i]; sum += array[i]; sum_sqr += pow(array[i], 2); } // Now, we have all 5 values inside the array, their sum and sum of their squares // proceeding with mean and sd, mean = sum/5; std_dev = sqrt((sum_sqr/5)-(pow(mean, 2))); // after writing these codes, I realise we didn't even need the array lol // but it's always good to keep a copy of the original data
2nd May 2017, 5:25 AM
Hatsy Rei
Hatsy Rei - avatar