Program to find the Hidden Number | Getting the size of array ; Getting the array of size n ; Solution ; Finding sum of the array elements ; Dividing sum by size n ; Print x , if found
< ? php $ n = 3 ; $ a = array ( 1 , 2 , 3 ) ; $ i = 0 ; $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ sum += $ a [ $ i ] ; } $ x = $ sum / $ n ; if ( $ x * $ n == $ sum ) echo ( $ x ) ; else echo ( " - 1" ) ; ? >