If both 4 s and 7 s are there in digit sum , we subtract a 4.
else { a ++ ; sum -= 4 ; } } if ( sum < 0 ) { printf ( " - 1n " ) ; return ; } for ( int i = 0 ; i < a ; i ++ ) printf ( "4" ) ; for ( int i = 0 ; i < b ; i ++ ) printf ( "7" ) ; printf ( " n " ) ; }