Scanf() is a function used to read input from the keyboard in C programs. It works similarly to printf() but reads input instead of writing output. Scanf() uses format specifiers in a control string to read input into variables. Common format specifiers include %d for integers, %f for floats, and %s for strings. Loops like for, while, and do-while can be used to repeat a block of code a specified number of times to perform tasks like calculating triangle numbers or factorials.