text: Undulating numbers | C # program to check whether a number is undulating or not ; Considering the definition with restriction that there should be at least 3 digits ; Check if all alternate digits are same or not . ; Driver code
code: using System ; class GFG { public static bool isUndulating ( string n ) { if ( n . Length <= 2 ) return false ; for ( int i = 2 ; i < n . Length ; i ++ ) if ( n [ i - 2 ] != n [ i ] ) return false ; return true ; } public static void Main ( ) { string n = "1212121" ; if ( isUndulating ( n ) == true ) Console . WriteLine ( " yes " ) ; else Console . WriteLine ( " no " ) ; } }