10 's Complement of a decimal number | C # program to find 10 's complement ; Function to find 10 's complement ; Calculating total digits in num ; restore num ; calculate 10 's complement ; Driver code
using System ; class GFG { static int complement ( int num ) { int len = 0 , temp , comp ; temp = num ; while ( true ) { len ++ ; num = num / 10 ; if ( Math . Abs ( num ) == 0 ) break ; } num = temp ; comp = ( int ) Math . Pow ( 10 , len ) - num ; return comp ; } public static void Main ( ) { Console . WriteLine ( complement ( 25 ) ) ; Console . WriteLine ( complement ( 456 ) ) ; } }