using System; class RootMeanSquare { // Entry Point public static void Main() { int[] arr = { 20, 8, 12, 16 }; int n = arr.Length; Console.Write(RMS_Value(arr, n)); Console.Read(); } // Root Mean Square static float RMS_Value(int[] arr, int n) { int square = 0; float mean, root = 0; // Calculate square for (int i = 0; i < n; i++) { square += (int)Math.Pow(arr[i], 2); } // Calculate Mean mean = (square / (float)(n)); // Calculate Root root = (float)Math.Sqrt(mean); return root; } }
Output