Using ANSI escape sequence it's possible to control the position of the cursor:
void gotoxy(int x, int y) {
printf("\033[%d;%dH",x,y);
}
So once you figure out the terminal height and width then you can use that function to position the cursor wherever you like and print stuff.