text: Probability of rain on N + 1 th day | C # code to find the probability of rain on n + 1 - th day when previous day 's data is given ; Function to find the probability ; count 1 ; find probability ; Driver Code
code: using System ; class GFG { static float rainDayProbability ( int [ ] a , int n ) { float count = 0 , m ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) count ++ ; } m = count / n ; return m ; } public static void Main ( ) { int [ ] a = { 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 } ; int n = a . Length ; Console . WriteLine ( rainDayProbability ( a , n ) ) ; } }