Interactive Problems in Competitive Programming |  ; Applying Binary Search interactively ; Print the guessed number ; Input the response from the judge
using System ; class GFG { static void Main ( ) { int lower_bound = 2 ; int upper_bound = 10 ; while ( lower_bound <= upper_bound ) { int mid = ( lower_bound + upper_bound ) / 2 ; Console . WriteLine ( mid ) ; int response = Convert . ToInt32 ( Console . ReadLine ( ) ) ; if ( response == - 1 ) { lower_bound = mid + 1 ; } else if ( response == 1 ) { upper_bound = mid - 1 ; } else if ( response == 0 ) { Console . WriteLine ( " Number ▁ guessed ▁ is ▁ : " + mid ) ; break ; } } } }