You need thread or process creation and some signal stuff.

Create a child process which will print the numbers and the parent process will take user input.