Hi
As a quick fix, put fflush(stdin); immediately after your scanf("%d",&x);
shabbir like this