This kind of problem is exactly why those of us that have been round the block a few times don't bother with scanf for input but use fgets to read a whole line of input from the user and parse it ourselves, e.g.:
printf("Enter a number :");
fgets(buf,30,stdin); // args may be the wrong way round here; this is from memory
printf("You entered %d\n",num);
scanf and family are best used when the exact input format is completely known, which is not the case for user input, and is certainly not the case when you don't really understand what it's doing. So I don't see why teachers insist on using scanf for input - maybe because it mirrors printf, but fgets is a lot more reliable and you can use fgets then sscanf if you really want to use a scanf-type function.